Multiple wildcards in One IF Statement or LOOKUP

OscarAGC

New Member
Joined
Feb 25, 2009
Messages
5
I have BSU's that share a prefix in this format- 7HP, 7AP, and have some letters after that for different departments.

Then I have indepenedent departments with no client prefix in this format- 2HO, 1HO,ZHO, etc.

I want to make an IF statement with multiple wildcards, something like this...

=if(isnumber(search("*7AP*",A1),"AP",search("*7HP*",A1),"HP",search("*2HO*",A1),"HO",search...etc....

I tried a lookup with wildcards, but that didnt work either.:(


Thanks to all who choose to help!:biggrin:
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
The search formula doesn't need the wildcards operators. It already searches for the text as a substring without those. That might work for you.

Another option is to put the search values in a lookup too... Just had some discussion on this recently:
http://www.mrexcel.com/forum/showthread.php?t=372923&page=2
(see Barry's post #12 and others).

HTH, Alex
 
Upvote 0
Try...

=LOOKUP(9.99999999999999E+307,SEARCH({"7AP","7HP","2HO"},A1),{"AP","HP","HO"})

or

=INDEX({"AP","HP","HO"},MATCH(TRUE,ISNUMBER(SEARCH({"7AP","7HP","2HO"},A1)),0))

...confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

Hope this helps!
 
Upvote 0
Isn't a lookup function a lot easier?

If it has "*bla*" in it, return "Bla Bla", if it has "*pla*" in it , return "Pla Pla"

That formula looks to be overkill. This can be done really simply with a Lookup function, I'm just having trouble with the syntax.
 
Upvote 0
It is overkill - quite a large number. But it is a lookup, and in fact a simple one in its own way.

Maybe you'd prefer this one, with a little less 9's?
=LOOKUP(9E+10,SEARCH({"7AP","7HP","2HO"},A1),{"AP","HP","HO"})
 
Upvote 0
You may like to have the lookup values in a small table rather than embedded in the formula - could be easier to maintain also:
book1
ABCDE
1OriginalValueLookupValueLookupTable
22HOHO7APAP
37HPHP7HPHP
42HOHO2HOHO
57APAP
6
Sheet1


I used Domenic's formula - sans writing a VBA custom function I can't find anything simpler for it.
In Cell B2:
=LOOKUP(9.999999999999E+307,SEARCH(A2,$D$2:$D$4),$E$2:$E$4)
 
Upvote 0

Forum statistics

Threads
1,215,460
Messages
6,124,949
Members
449,198
Latest member
MhammadishaqKhan

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