search multiple text strings in a cell

joecast

Board Regular
Joined
Mar 4, 2010
Messages
52
hello all,
have this formula working:

Code:
=IF(ISERROR(SEARCH("PS",Table_Query_from_NAV[[#This Row],[No_]])),VLOOKUP(Table_Query_from_NAV[[#This Row],[No_]],Facility_Table,4,TRUE),"Linear Asset Type")

which is great, however, now i need to search for two other text strings. i have tried using OR, but may not be trying it in the right place or in the right way. so basicallyinstead of just searching "PS", i need to search "PS", "MH" or "SEG", and possibly others later on. any suggestions? thanks
joe
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi Joe

Perhaps:

=IF(SUM(COUNTIF(Table_Query_from_NAV[[#This Row],{"*PS*","*MH*","*SEG*"})),Vlookup(Table_Query_from_NAV[[#This Row],[No_]],Facility_Table,4,TRUE),"Linear Asset Type")
 

joecast

Board Regular
Joined
Mar 4, 2010
Messages
52
thanks Richard,
the countif is only giving a result for the first value "*PS*", the others are not registering. tried switching the arguments, but only first one works. have seen
{"*PS*","*MH*","*SEG*"}
used but dont understand the logic so cant tell if it should work for countif. im guessing it is doing a rough OR kind of thing? thanks
joe
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
I did get the logic round the wrong way - think it should have been:

=IF(SUM(COUNTIF(Table_Query_from_NAV[[#This Row],{"*PS*","*MH*","*SEG*"}))=0,Vlookup(Table_Query_from_NAV[[#This Row],[No_]],Facility_Table,4,TRUE),"Linear Asset Type")

However, as far as I know that should work (although I don't have 2007 or 2010 to test on Table ranges I'm afraid).
 

joecast

Board Regular
Joined
Mar 4, 2010
Messages
52
YEEEES!!
thats got it! didnt reralise it was a CSE formula. Thanks
joe

=IF(SUM(COUNTIF(Table_Query_from_NAV[[#This Row],[No_]],{"*PS*","*MH*","*SEG*"}))=0,VLOOKUP(Table_Query_from_NAV[[#This Row],[No_]],Facility_Table,4,TRUE),"Linear Asset Type")
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,434
Messages
5,837,215
Members
430,484
Latest member
himaruasuka

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
Top