Question on IF(SEARCH formula

9320blue

New Member
Joined
Aug 9, 2022
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hello, I have a formula that finds a keyword in one column and places a different keyword in a seperate column and if it does not find it it is left blank. That works great but I want to do this with multiple words on the same columns. I have tried using AND/OR but it does not work.

Here is what works:

=IF(SEARCH("COLLINSVILLE",[@City],1),"MADISON")

This searches the City column for the work COLLINSVILLE and enters the work MADISON into my new column right next to it. I then added one for MT VERNON and JEFFERSON but it doesn't work.

=IF(SEARCH("COLLINSVILLE",[@City],1),"MADISON") OR (IF(SEARCH("MT VERNON",[@City],1),"JEFFERSON")
 

Attachments

  • EXCEL SNIP.PNG
    EXCEL SNIP.PNG
    40.7 KB · Views: 9

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Welcome to the MrExcel board!

It looks like you would have quite a lot of different City/County combinations. I would suggest setting up another table with those combinations. Something like I have in columns K:L below. I have named that table as 'Counties". Then you can use the formula shown in the left hand table to retrieve the County names.

9320blue.xlsm
CDEFGHIJKL
1CityStatePCCountyCityCounty
2COLLINSVILLECounty 1COLLINSVILLECounty 1
3MT VERNONCounty 2GRANITE CITYCounty 4
4MARYVILLECounty 3HIGHLANDCounty 1
5GRANITE CITYCounty 4MARYVILLECounty 3
6STOWNot foundMT VERNONCounty 2
7HIGHLANDCounty 1
8
Sheet1
Cell Formulas
RangeFormula
F2:F7F2=IFNA(VLOOKUP([@City],Counties,2,0),"Not found")


BTW, I suggest that you investigate the following for any future questions.
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,124
Members
453,021
Latest member
Justyna P

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