If or not formula help

notarobot

New Member
Joined
Feb 6, 2017
Messages
4
I'm trying to create a formula that produces a certain value based on a list of options.

Essentially, I want to know whether a someone associated with a city should be placed in "Zone 1", "Zone 2", or "Zone 3". "Zone 1" and "Zone 2" have a set of values associated with them, and then "Zone 3" is everything else.

As an example, let's say Zone 1 represents a certain list of cities--Austin, New York, Philly, Zone 2 represents a certain list of cities--Seattle, Atlanta, Chicago, and Zone 3 is all other cities not listed in Zones 1 or 2.

Any help would be great!
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
welcome to the forums. try something like the below (copy/paste)...

E2: =IF(ISNUMBER(MATCH($D2,$A$2:$A$7,0)),VLOOKUP($D2,$A$2:$B$7,2,0),"Zone 3")

ZonesCitiesCitiesZone?
AustinZone 1New YorkZone 1
New YorkZone 1PhillyZone 1
PhillyZone 1ChicagoZone 2
SeattleZone 2Los AngelesZone 3
AtlantaZone 2AustinZone 1
ChicagoZone 2BostonZone 3

<tbody>
</tbody>
 
Last edited:
Upvote 0
Here's another option, if the cell with your city might have more of an address:

Excel 2012
ABCDEF
1NameAddrZoneCityZone
2Al100 Main New YorkZone 1AustinZone 1
3Bob200 State AtlantaZone 2New YorkZone 1
4Carol300 East CharlestonZone 3PhillyZone 1
5Diane400 South SeattleZone 2SeattleZone 2
6EdZone 3AtlantaZone 2
7ChicagoZone 2
8PortlandZone 2
9
10

<colgroup><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
C2=IFERROR(LOOKUP(2,1/(FIND($E$2:$E$10,B2)*($E$2:$E$10<>"")),$F$2:$F$10),"Zone 3")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
This will work

create this table in A1:B6 for example

Austin Zone 1
New York Zone 1
Philly Zone 1
Seattle Zone 2
Atlanta Zone 2
Chicago Zone 2


=+IFERROR(VLOOKUP(<city to search>,$A$1:$B$6,2,FALSE),"Zone 3")
 
Upvote 0
Inspired by Eric's formula... you could condense mine down to just the below:

=IFERROR(VLOOKUP($D2,$A$2:$B$7,2,0),"Zone 3")
 
Last edited:
Upvote 0
One way...

Data Range
A
B
C
D
E
1
Pittsburgh​
Zone 3​
------​
Austin​
Zone 1​
2
New York​
Zone 1​
3
Philly​
Zone 1​
4
Seattle​
Zone 2​
5
Atlanta​
Zone 2​
6
Chicago​
Zone 2​

Create the table in D1:E6.

Then, this formula entered in B1:

=IFERROR(VLOOKUP(A1,D1:E6,2,0),"Zone 3")
 
Upvote 0
Awesome--thanks so much! These will definitely work well.

not to be picky, but rather curious, is there a way to write a formula without some lookup from an additional table?
 
Upvote 0
not to be picky, but rather curious, is there a way to write a formula without some lookup from an additional table?
You could "build" the table directly into the formula or you could use nested IF functions.

If you have "many" cities to evaluate this could lead to a very long formula.
 
Upvote 0
Yeah... I couldn't quite get the nested if aspect down, especially to add a not zone 1 and 2 clause to label zone 3 cities. I just want to see what it would look like for future reference.

You could "build" the table directly into the formula or you could use nested IF functions.

If you have "many" cities to evaluate this could lead to a very long formula.
 
Upvote 0
Yeah... I couldn't quite get the nested if aspect down, especially to add a not zone 1 and 2 clause to label zone 3 cities. I just want to see what it would look like for future reference.

Something along the lines of

=IF(OR(A1={"Austin","New York","Philly"}),"Zone 1",IF(OR(A1={"Seattle","Atlanta","Georgia"}),"Zone 2","Zone 3"))
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,982
Members
449,201
Latest member
Lunzwe73

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