An IF statements that operates if a cell CONTAINS any one of a LIST of words...

DrPhilBurns

New Member
Joined
Sep 16, 2015
Messages
5
[FONT=&quot]I know how to write an IF statement that looks at a string of text, and will perform an action if the string CONTAINS a certain "word" using
[/FONT]
[FONT=&quot]=IF(ISNUMBER(SEARCH("*word*",A1)),"word","")
[/FONT]
[FONT=&quot]
[/FONT]
[FONT=&quot]But
Is it possible to write an IF statement that looks at a string of text, and will perform an action if the string CONTAINS any one of a list of certain words?
e.g.
[/FONT]
[FONT=&quot]I have a list of addressess which include the country. I want to do something based on whether the address is in Europe
using similar notation as above, I need something like:
[/FONT]
[FONT=&quot] =IF(ISNUMBER(SEARCH("*
  • *",A1)),"europe","")
    where LIST is a range of cells containing all the European countries "France, Germany, Denmark, ...."[/FONT]
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try to describe a problem in words instead of a possible, non-working solution.

Guessing at your problem, try:

=LOOKUP(9.99999999999999E+307,SEARCH(" "&EuropeList&" "," "&A1&" "),EuropeList)
 
Upvote 0
I have figured out the first part of my problem using the formula (which works):
=IF(SUMPRODUCT(--ISNUMBER(SEARCH(Europe,J8))),"Europe","NOT")
where "Europe" is a named list including all the European countries - this returns "Europe" if the address contains a country in the list and "Not" if not.


Next question is:
Is it possible to take the above solution one step further and return the actual matched country from the address?
e.g. if the address contains "France", then the formula returns "France" and so on for each country in the named list Europe?
 
Upvote 0
I have figured out the first part of my problem using the formula (which works):
=IF(SUMPRODUCT(--ISNUMBER(SEARCH(Europe,J8))),"Europe","NOT")
where "Europe" is a named list including all the European countries - this returns "Europe" if the address contains a country in the list and "Not" if not.


Next question is:
Is it possible to take the above solution one step further and return the actual matched country from the address?
e.g. if the address contains "France", then the formula returns "France" and so on for each country in the named list Europe?

See post #2 ...
 
Upvote 0

Forum statistics

Threads
1,216,081
Messages
6,128,696
Members
449,464
Latest member
againofsoul

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