Keyword Match Vlookup

teek0001

New Member
Joined
Apr 21, 2014
Messages
2
I have a huge list of locations that are written in a variety of formats (city/country, region/country, city/state/country, etc.). I want to just pull the country out of the cell and disregard the other information. I have a master list of every country in a separate sheet and was wondering if there was an easy way to create a vlookup that would only spit out the country name when it is mentioned in the list of locations. Hope that makes sense
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Is the country always the last listed item? And are the values always separated by "/"?
 
Last edited:
Upvote 0
Is the country always the last listed item? And are the values always separated by "/"?

The country is usually the last listed item. They are not separated by a slash[TABLE="width: 178"]
<colgroup><col></colgroup><tbody>[TR]
[TD]10KM SW of Pointe Claire, Montreal, Canada[/TD]
[/TR]
</tbody>[/TABLE]

The above is an example of a cell.
 
Upvote 0
Let's try:

=LOOKUP(9.99999999999999E+307,(SEARCH(" "&CountryList&" "," "&A2&" "),CountryList)

where A2 houses a string like above.
 
Upvote 0
If I may ask a question... I tried recreating this scenario and the formula above works great for when the country is at the end of the string. However, when I got curious and decided to pick this apart and tried just the search() formula to see what results, it's returning #VALUE!. Is this simply because it is referring to the named range instead of a single cell and the larger formula is able to handle that? If you have a moment, an explanation of how this worked would be awesome and greatly appreciated.
 
Upvote 0
If I may ask a question... I tried recreating this scenario and the formula above works great for when the country is at the end of the string.

It should also work with country anywhere in the string.

However, when I got curious and decided to pick this apart and tried just the search() formula to see what results, it's returning #VALUE!. Is this simply because it is referring to the named range instead of a single cell and the larger formula is able to handle that? If you have a moment, an explanation of how this worked would be awesome and greatly appreciated.

All countries in the (named) range are searched in the target string (in A2) all at once. The following link contains an explanation:

http://www.mrexcel.com/forum/excel-questions/724843-there-case-sensitive-vlookup.html#post3567172

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,307
Members
452,633
Latest member
DougMo

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