Consulting

Results 1 to 3 of 3

Thread: Userform search is not working after delete any record

  1. #1
    VBAX Contributor
    Joined
    Jun 2019
    Posts
    155
    Location

    Userform search is not working after delete any record

    ​Dear Team,


    I had created the userform for Add, Update, Delete the customer details. And I am having listbox for search the customers.


    In this once I entered any value on Combobox2( for search customer name), the listbox will update ​automatically by filtering the data in sheet "Customer data" by partially matching​​ the value typed in Combobox2 and It is working for all the function properly.


    But when I am delete any customer through the userform, after that the autofilter partially not working. When the whole value is matching then only the listbox is updating.


    And I want to update the header for my listbox. The header range is Sheet"Customer Data" ("A2:H2").


    I don't know where I am doing mistake.


    I am attaching my file here for your reference.


    Please help me to solve this issue
    Attached Files Attached Files

  2. #2
    VBAX Contributor
    Joined
    Jun 2019
    Posts
    155
    Location
    Dear Team,

    Any one please reply to my query

  3. #3
    VBAX Contributor
    Joined
    Jun 2019
    Posts
    155
    Location
    Dear Team,

    I changed the delete button code to

    Private Sub CommandButton5_Click()
    
    'For delete the customers
    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets("Customer Data")
    Dim Selected_Row As Long
    Selected_Row = Application.WorksheetFunction.Match(Me.customername.Value, sh.Range("B:B"), 0)
    sh.Range("B" & Selected_Row).EntireRow.Delete
    
    
    Dim sh1 As Worksheet
    Set sh1 = ThisWorkbook.Sheets("Master data")
    Dim Selected_Row1 As Long
    Selected_Row1 = Application.WorksheetFunction.Match(Me.customername.Value, sh1.Range("B:B"), 0)
    sh1.Range("B" & Selected_Row1).EntireRow.Delete
    
    
    Call Clear
    End Sub
    Now my search button is working properly even if i delete any values.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •