• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA: Display rows that matches the entered search string [SOLVED]

inddon

Member
Hello There,

I have 2 columns, ID (Column C) and Name (Column D). Labels are on the 5th row and data starts from 6th row

I have made the cell D3 where the you can enter the partial string of the name. A button next to it.

When you press the button 'Search', it should display all the names that matches the entered string. I would not like to use a table.

Attached is the sample workbook for your reference.

Could you advise and help, how this can be achieved through VBA?
 

Attachments

  • Search Names.xlsx
    12.7 KB · Views: 4
Hi Inddon

I might suggest an alternative. Take the button out and just have a worksheet change event. Some thing like the following.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
    If Not Intersect(Target, [D3]) Is Nothing Then
        Set rng = Range("D5", Range("D" & Rows.Count).End(xlUp))
        rng.AutoFilter 1, "*" & [D3] & "*", , , 0
    End If
End Sub

I will attach a file to show workings. Type the test names in D3 also if you want all names hit delete and hit enter.
 

Attachments

  • Search Names.xlsm
    18.4 KB · Views: 7
Hi Inddon

I might suggest an alternative. Take the button out and just have a worksheet change event. Some thing like the following.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
    If Not Intersect(Target, [D3]) Is Nothing Then
        Set rng = Range("D5", Range("D" & Rows.Count).End(xlUp))
        rng.AutoFilter 1, "*" & [D3] & "*", , , 0
    End If
End Sub

I will attach a file to show workings. Type the test names in D3 also if you want all names hit delete and hit enter.


Wonderful Smallman. Thanks a lot for your help and solution.

Could you please tag this post as [SOLVED], on my behalf.

Regards
Don
 
Back
Top