Search table using partial text and return all matches

Smithy2k7

New Member
Joined
Aug 14, 2014
Messages
29
Hello, I have a table which when completed will be used as a point of reference to find part numbers etc. I am looking to set up a search box which when a partial search string such 'BATT' is entered, it will return all matches in the table which contains 'BATT'.

Column A is stock number, column B is Type and column C is description. When part descriptions are entered I would like it to return all matches using the description, but to also to return the stock number of the matched items.

Thanks.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
.
.

You could use conditional formatting, which, in turn, will enable you to filter by cell colour.


(1) Highlight column C (containing your descriptions);

(2) Create a conditional formatting rule; and

Home --> Styles --> Conditional Formatting --> Highlight Cells Rules --> Text that Contains...

(3) In the input box, enter the address of the cell in which users enter the text.
 
Upvote 0
This database is ultimately going to contain hundreds of entries, possibly thousands so although that way would work I dont want the end user to have filter by colour etc. My idea and hope, is that the user types in a criteria, lets say 'Bat' because he/she doesnt know the exact name of what they want. I'd like it to return in separate rows, all entrys containing 'Bat' along with the stock number in column A.

Thanks
 
Upvote 0
.
.

Perhaps you can adapt something like the following.

(Note that the code should be placed in the code module for that particular worksheet.)

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim Crit As Range
    Dim FCnt As Integer
    Dim i As Integer
    
    'set cell for search criteria
    Set Crit = Me.Range("J1")
    
    If Target.Address = Crit.Address Then
        Application.ScreenUpdating = False
        
        'clear existing filter
        On Error Resume Next
        Me.ShowAllData
        On Error GoTo 0
    
        With Me.Range("A1").CurrentRegion
            
            'add filter with hidden dropdown
            FCnt = .Columns.Count
            For i = 1 To FCnt
                .AutoFilter Field:=i, VisibleDropdown:=False
            Next i
            
            'filter by search criteria
            .AutoFilter Field:=3, Criteria1:="=*" & Crit.Value & "*"
        End With
            
        Application.ScreenUpdating = True
        Crit.Select
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,881
Messages
6,122,074
Members
449,064
Latest member
MattDRT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top