Search a database with wildcards

ThatOneDude

New Member
Joined
Aug 11, 2022
Messages
14
Office Version
  1. 365
Platform
  1. Windows
I have a large database that I need to search but I'm struggling with getting this to happen the way I'd like it to.

Let's say the lookup range includes:
ABC123
ABC223
ABC1234
ZABC1234

Then, I have cell A1 that contains the value ABC*23.

When I use the SEARCH function to search the range using A1 as the lookup value, it will return all four of those values because it searches for the cell value anywhere within the lookup range. In this situation, what I would like it to return is ABC123 and ABC223 only. If cell A1 was ABC*23*, then I would expect ABC123, ABC223 and ABC1234. I don't want the ZABC1234 result at all unless the value in A1 starts with Z or *.

Is there a way to search using the exact text in the cell and only including results that have additional characters where the wildcards are located only?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
1660286545061.png
 
Upvote 0
Thank you for your reply. The thing is, I need this to happen automatically with a formula and I get the same results whether using FIND or SEARCH.
 
Upvote 0
Would this work for you
Book2
AB
1ABC1231
2ABC2231
3ABC1234 
4Zabc1234 
Sheet1
Cell Formulas
RangeFormula
B1:B4B1=IFNA(MATCH("ABC*23",A1,0),"")
 
Upvote 0
The issue there is that ABC*23 would actually be the value in a cell so the cell reference would be the only thing in the formula. Then, there would be multiple results that I am listing in the same cell using TEXTJOIN. The MATCH function only returns the first result. I'm then joining all the results into one cell using TEXTJOIN.
 
Upvote 0
How about
Fluff.xlsm
ABCDE
1
2ABC123abc*23*ABC123abc*23ABC123
3ABC223ABC223ABC223
4ABC1234ABC1234
5ZABC1234
6
Data
Cell Formulas
RangeFormula
C2:C4C2=FILTER(A2:A5,ISNUMBER(SEARCH(" "&B2&" "," "&A2:A5&" ")))
E2:E3E2=FILTER(A2:A5,ISNUMBER(SEARCH(" "&D2&" "," "&A2:A5&" ")))
Dynamic array formulas.
 
Upvote 0
Solution
Hm.....so, simply adding a space before and after my lookup value and also the values in the lookup table accomplishes my goal. I never thought of that. Thank you!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,654
Messages
6,120,758
Members
448,991
Latest member
Hanakoro

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