using an if statement to reference a collumn

burnsa9

New Member
Joined
Jul 20, 2017
Messages
11
Hello, I am trying to create a large loop that will reference my column called cities. I want the loop to refernce cities and put the state of these locations in a new column with the header state. My table is below. I have 5 different cities Memphis, Sand Diego, Seatle, Portland, and Charlotte.
[TABLE="width: 500, align: center"]
<tbody>[TR]
[TD]Market [/TD]
[TD]Day of the week [/TD]
[TD]Country [/TD]
[TD]State[/TD]
[/TR]
[TR]
[TD]Memphis [/TD]
[TD]Sunday [/TD]
[TD]United states [/TD]
[TD][/TD]
[/TR]
[TR]
[TD]San Diego [/TD]
[TD]Saturday [/TD]
[TD]United States [/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Seatle [/TD]
[TD]Monday [/TD]
[TD]United states [/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
You can use a VLOOKUP where A2 has the city and H1:I3 has the city and state list.
Code:
=VLOOKUP(A2,$H$1:$I$3,2,0)

If you do not want to have the list off to the side you can put it into the vlookup like this
Code:
=VLOOKUP(A2,{"Memphis","TN";"San Diego","CA";"Seatle","WA"},2,0)
 
Upvote 0
The formula gives the state. it looks up the city and returns the state form the list.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
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