# How to do this IF?

#### bpflyr

##### Board Regular
I have a list of about 200 rows with different 3 letter codes. There are about 150 different codes. How can I get Excel to:

If B1=TEB then return "Teterboro, NJ" in cell D1.
If B1=LGA then return "New York, NY" in cell D1.

So forth and so on for all 150 different code posibilities.

I will be entering the data in column B, but need Excel to return the answer in D.

How do I or can I do this?? Thank you so much in advance.

### Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I guess you have to create a macro for that

Any idea how to do that would be greatly appreciated

a quick way would be on a separate sheet to put the 3 letter codes in one column and the place names beside them in a second column

Then do a Lookup based on the value in B1 returning the answer to D1

eg;
=LOOKUP(B1, range of values to lookup , range of values to return )

I would go with Fat Cat's idea... it would be easier to modify as well

Fat Cat said:
a quick way would be on a separate sheet to put the 3 letter codes in one column and the place names beside them in a second column

Then do a Lookup based on the value in B1 returning the answer to D1

eg;
=LOOKUP(B1, range of values to lookup , range of values to return )

And sort the 2-column table (say in F2:G100) on its first column if you want to invoke a LOOKUP formula. BTW, such a formula needs to be carefully crafted:

=LOOKUP(B1,\$F\$2:\$F\$10,\$G\$2:\$G\$100)

if B1 is selected from a dropdown list, constructed from the first column of the sorted table. Otherwise:

Replies
8
Views
355
Replies
3
Views
221
Replies
17
Views
295
Replies
1
Views
184
Replies
0
Views
380

1,206,827
Messages
6,075,099
Members
446,121
Latest member
Malikai

### 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?

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