Looking up, Matching, or indexing???

Marc Enzi

Board Regular
Joined
Dec 13, 2004
Messages
92
I am compiling a list of Countries and Airports from different sources. I am trying to get the Country Code from one list to Match Up with the Country.

I am a novice and this is a bit out of my grasp.

Here is an excerpt from the list of Airports
Airport.......Code.............Country Name....Country Code
Aarhus...........AAR..............Denmark........... ?
Aberdeen.......ABZ...............UK................... ?
Aberdeen, SD.ABR...............USA................. ?


Here is an excerpt from the Country List

Country List....................Country Codes List
ALBANIA.............................AL
Denmark............................DK
ANGOLA..............................AO
ANGUILLA...........................AI
UAE...................................AE
UK.....................................GB
USA...................................US

My goal is to have the Country Code Come Up at the far right in the 1st table above given a particular Country Name...

Thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
How do you want to do it?

A Sheet Formula or by VBA code?

For a Sheet formula try: VLookUp

For code try: OffSet
 
Upvote 0
Yes, I have been trying VLookup, but am having some problems like I keep getting Uruguay UY matching up with USA.

I think there is a way to get it to match up exactly.

I am compiling a rather large list and I want this to be robust enough to handle differences like Caps and lower case and perhaps misspellings...
 
Upvote 0
How have you tried VLOOKUP?

Are you setting the last argument to FALSE?
 
Upvote 0
Hi,

It looks like you want to use the VLOOKUP function.

So in the first line of records in the Country Code cell that has a "?", you want to use the VLOOKUP function. For example, say the AIRPORT column is column A and CODE is column B, and the first record, Aarhus is row 2 etc.

Now, depending where the separate Country Code list is located (if it is in the same workbook on a different worksheet, or in a different workbook), say the COUNTRY LIST is in column A and the COUNTRY CODE LIST is in column B, you would write something like the following in the COUNTRY CODE cell where you want the result to be in place of the "?", which would be in D2:

=VLOOKUP(A2,Country Code List!A:B, 2, 0)

If you follow what I have said, everything in the previous example will be the same except for the 'Country Code List!A:B' part. It depends where the Country Code List is. If it is in the same workbook, that relates to my example above, which would say that the Country Code List exists in the same workbook on a separate worksheet where that worksheet has the name of Country Code List, and the actual list is contained in columns A and B.

You can use the wizard, which will walk you through the structure of the function. I suggest you google the VLOOKUP function, with what I have given you, you should be able to figure it out.
 
Upvote 0
Marc Enzi said:
Yes, I have been trying VLookup, but am having some problems like I keep getting Uruguay UY matching up with USA.

I think there is a way to get it to match up exactly.

I am compiling a rather large list and I want this to be robust enough to handle differences like Caps and lower case and perhaps misspellings...
Book7
ABCDEFG
1AirportCodeCountry NameCountry CodeCountry ListCountry Codes List
2AarhusAARDenmarkDKALBANIAAL
3AberdeenABZUKGBANGOLAAO
4Aberdeen, SDABRUSAUSANGUILLAAI
5DenmarkDK
6UAEAE
7UKGB
8USAUS
Sheet1


If F2:G8 is sorted on F in ascending order, you can invoke:

D2:

=IF(LOOKUP(C2,$F$2:$F$8)=C2,LOOKUP(C2,$F$2:$G$8),"Not Listed")

Otherwise:

=VLOOKUP(C2,$F$2:$G$8,2,0)

The first formula is faster.
 
Upvote 0
Index?? What is wrong with my formula?

I am a bit of a novice an dhaving difficulty getting the index function to work for me.

I am trying to use the following formula to pull 4 letter ICAO airport codes from a list with corresponding 3 letter IATA codes.

Here is what I am using but I keep getting #N/A
in sheet named mergeIATAdb

I am using a formula in column E, I want it to use the 3 letter code in column B containing the letter IATA airport code and search another sheet named paid50 for the corresponding 4 letter ICAO code.

=INDEX(paid50!$A$1:$A$50000,MATCH(B2,paid50!$B$1:$B$50000,0))

THis is what the mergeIATAdb sheet looks like
Column B Column E
IATA_Code...ICAO_Code
CRP.............#N/A

In the paid50 sheet I plainly see
Column A.....Column B.....Column C
IATA_Code...ICAO_Code...Airport_Name...
CRP............KCRP............Corpus Christi Intl Airport

I feel kind of stupid, I have two Excel books and I still can't get this to work...

Thanks for any help.
 
Upvote 0
Re: Index?? What is wrong with my formula?

Marc Enzi said:
I am a bit of a novice an dhaving difficulty getting the index function to work for me.

I am trying to use the following formula to pull 4 letter ICAO airport codes from a list with corresponding 3 letter IATA codes.

Here is what I am using but I keep getting #N/A
in sheet named mergeIATAdb

I am using a formula in column E, I want it to use the 3 letter code in column B containing the letter IATA airport code and search another sheet named paid50 for the corresponding 4 letter ICAO code.

=INDEX(paid50!$A$1:$A$50000,MATCH(B2,paid50!$B$1:$B$50000,0))

THis is what the mergeIATAdb sheet looks like
Column B Column E
IATA_Code...ICAO_Code
CRP.............#N/A

In the paid50 sheet I plainly see
Column A.....Column B.....Column C
IATA_Code...ICAO_Code...Airport_Name...
CRP............KCRP............Corpus Christi Intl Airport

I feel kind of stupid, I have two Excel books and I still can't get this to work...

Thanks for any help.

Is paid50 sorted in ascending order on IATA_code?
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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