If Statement with multiple expressions?

CatCity

New Member
Joined
Apr 4, 2016
Messages
1
I am trying to create a zip code lookup for our database, to help place people in the appropriate town or county.
Currently, I am creating the If statements one by one, for example - IIf([Zip_Code]="97211","Portland","")

How can I create an If statement that allows multiple zip codes to return the result "Portland". For example, I would like my If statement to include the Zip code 97211, 97227, 97221 and return the result "Portland."
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Welcome to the forum.

The simplest way is this: =IF([Zip_Code]={97211;97227;97221},"Portland","")

I suspect you'll have a need to look up all kinds of codes in a reference table of dozens of cities and their corresponding codes. Is that so?
 
Upvote 0
Welcome to the Board!

Since you posted this in the Access forum and mentioned IIF instead of IF, I assume that this is an Access question and not an Excel one (so the first response will not work for Access, as it is an Excel reply).

Basically, in Access, you typically would NOT use IIF statements for something like this. You would create a table with you link to to get your answer. Your table would have two columns - Zip Code and City. Your Zip Code would be your unique Primary Key. So then you would just link this table to your other table on the Zip Code field to return your City value.
 
Upvote 0

Forum statistics

Threads
1,221,821
Messages
6,162,157
Members
451,750
Latest member
pnkundalia

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