Vlookup with wildcard to return multiple results from text field

trw1976

New Member
Joined
Jan 10, 2019
Messages
9
I would like to create a very simple Lookup file that I can share with technicians to help them lookup parts. Basically, My file would take a text entry, say Bearing, go to the mass data sheet, find the word bearing in any cell, then return the value from a specified cell matching that row. Basically, I want it to function just like the search box under the drop down for a filter radio button. as you start typing, results start to refine as you get closer to the right result.

The problem is with VLOOKUP, and or Index Match, I can only return one value. I need to return all values, that have all of the text entered into the criteria box.

In other words, If I type Bearing, only one result comes back with these formulas. I would like a column to populate beneath the text box with all possibilities
LISTNUMBERLOOKUP*BEARING*(FORMULA PASTED DOWN THIS COLUMN WOULD BRING MULTIPLE RESULTS)
BEARING,DI,1",FLANGE1268012680
BEARING;SS,PILLOWBLOCK,1''1234512345
BEARING;SS,FLANGE,1''1234612346
MOTOR;400HP,4160VAC1234712490
CHAIN;ROLLER,4012355
SPROCKET;15 TOOTH,DI12378
BEARING;DI,FLANGE,2''12490
VALVE;SOLENOID,24VAC13579

<tbody>
</tbody>


I would like it to work so that if I added say, SS to cell D1 in the example above in additon to the word bearing, it would then filter down to only those numbers with both Bearing, and SS, regardless of the sequence they occur in the list. I.E.... D1=*BEARING**SS*, results would be listed below as 12345 and 12346, but not 12490 OR 12680.

I have tried on another conversation in here, where they were doing something similar, but have had no luck getting it to work on anything but the first cell, or I just receive seemingly random results. Also, in my mass data, the word Bearing, for example, may or may not be first in the nomenclature sequence...
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
A method using 2 helper columns (C and D), and value to be searched in E1
- helper columns could be hidden after testing

in C2 copied down to last row of data
=ISNUMBER(SEARCH(E$1,A2))*1

in D2 copied down to last row of data
=IF($C2=1,COUNTIF($C$2:$C2,1),"")

in E2 copied down to last row of data
=IFERROR(INDEX($B:$B,MATCH(ROWS(D$2:D2),D:D,0)),"")

Excel 2016 (Windows) 32 bit
A
B
C
D
E
1
LISTNUMBERHelper1Helper2
Bearing
2
BEARING,DI,1",FLANGE
12680​
1​
1​
12680​
3
BEARING;SS,PILLOWBLOCK,1''
12345​
1​
2​
12345​
4
BEARING;SS,FLANGE,1''
12346​
1​
3​
12346​
5
MOTOR;400HP,4160VAC
12347​
0​
12490​
6
CHAIN;ROLLER,40
12355​
0​
7
SPROCKET;15 TOOTH,DI
12378​
0​
8
BEARING;DI,FLANGE,2''
12490​
1​
4​
9
VALVE;SOLENOID,24VAC
13579​
0​
Sheet: Sheet1
 
Upvote 0
My search data actually resides on another sheet on sharepoint that is updated weekly, would I need the helper columns in the search data, or could I place the helper columns still on the sheet with the search tool?

I can try both ways. Will let you know how it goes...
 
Upvote 0
It works well, but is slow, and I do not believe it is refining the search when multiple criteria is input. If I put BEARING, I get 772 results from mass data. If I put *Bearing**1*, I get 772 results.

Also, before I get down the page with 90,000 lines, Excel faults out due to too much data.
 
Upvote 0
I also notice, it is returning things not related to the entered text, I get number 10000047 for example, which has description "PUMP:DIAPH;1 IN RF FLNGD INLET" amongst others...
 
Upvote 0
I believe this is due to the "NG" in FLNGD portion of the text it is finding. I see other examples, and they all seem to have two letters in concession related to the search term entered into what would be E1 in your example.
 
Upvote 0
Bearing????F
= Bearing followed by any 4 characters followed by F
Finds 12346, 12490 in sample data

Bearing*F
= Bearing followed by any number of characters followed by F
Finds 12680, 12346, 12490 in sample data

Further reading on wildcards https://exceljet.net/glossary/wildcard
 
Upvote 0
I was finally able to find a solution to this.

It is excel 2010 Magic Trick 798

This solution works great, and I am able to return a table, to one sheet that's hidden, then put critieria 2 and look at that table, narrow that one to another sheet, then put in my third criteria, which then populates the main search table with a much narrowed down list of possibilities.

The calculations are slow, however, does anyone have a different solution that may be faster?
 
Upvote 0
Using formulas will always be slower that using Data Filter
- a suitable solution for you would be Advanced Filter combined with a small amount of VBA

Follow these instructions to the letter, and then tell me if you think this could be a suitable method for you
- it has been set up in a very simplistic way to pander to the specific needs of advanced
- it can be enhanced later to make it more user friendy (eg you may prefer the input to be in ONE cell)
- it can be enhanced later to increase functionality

1. Copy the data below and paste into a NEW worksheet
- make sure the data is in EXACTLY the same cells
- A1:G13 must be identical

2. Right-Click on sheet tab \ select View Code \ paste the code below into the code window \ go back to Excel with {ALT}{F11}

3. To get an idea how it works ...
Type bear into cell A2 and select any cell in row 3
Type s into cell B2 and select any cell in row 3
Type 1 into cell C2 and select any cell in row 3
Type pill into cell D2 and select any cell in row 3

4, Select any cell in row 1 or row 4 to clear the filter

5. Select any cell in row 2 and the value in that cell is cleared

6. The workbook must be saved as type macro-enabled

The data
Excel 2016 (Windows) 32 bit
A
B
C
D
E
F
G
1
LISTLISTLISTLISTLISTLISTLIST
2
4
5
LIST
6
BEARING,DI,1",FLANGE
7
BEARING;SS,PILLOWBLOCK,1''
8
BEARING;SS,FLANGE,1''
9
MOTOR;400HP,4160VAC
10
CHAIN;ROLLER,40
11
SPROCKET;15 TOOTH,DI
12
BEARING;DI,FLANGE,2''
13
VALVE;SOLENOID,24VAC
Sheet: Sheet4

Code
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    On Error Resume Next
    If Target.CountLarge > 1 Then Exit Sub
    Dim critRng As Range: Set critRng = Range("A2:F2")
    Select Case Target.Row
        Case 2:             Target.ClearContents
        Case Is = 1, 5:     Me.ShowAllData: critRng.ClearContents
        Case Else
            Call Wildcard(critRng, True)
            Range("A5").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("A1:G2"), Unique:=False
            Call Wildcard(critRng, False)
        End Select
End Sub
Private Sub Wildcard(rng As Range, Yes As Boolean)
    Dim cel As Range
    For Each cel In Range("A2:F2")
        If Not Yes Then
            cel = Replace(cel, "*", "")
        Else
            If Len(cel) > 0 Then cel = "*" & cel & "*"
        End If
    Next
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,091
Messages
6,123,062
Members
449,090
Latest member
fragment

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