Cleaning address data

dunlopoil

Board Regular
Joined
May 29, 2008
Messages
92
Hi,
I have a database of sales records containing 6 address columns (C-H). I want to extract the country (which may be entered in any of the 6 columns) and place this in a separate column. I have a definitive list of countries on sheet 2 which I have saved as a named range (Country).

I would like to be able to set something up which searches the six address fields on sheet 1 and if a match is found against the Country range, enter this in a separate column (I). A non-code solution would be ideal as I am nowhere near that level yet and want to be able to understand what I am doing as far as possible!

Many thanks,
Doug.
 
Blimey, 5.1Mb!

Anyway, the problem was easy, SPAIN in your CountryList is actually SPAIN+space. You could get rid of it, but there are many others, so this formula handles it, and commas and dots

=IF(ISNA(MATCH(TRUE,ISNUMBER(MATCH(SUBSTITUTE(SUBSTITUTE(TRIM(C2:H2),".",""),",",""),TRIM(CountryList),0)),0)),"",
INDEX(C2:H2,MATCH(TRUE,ISNUMBER(MATCH(SUBSTITUTE(SUBSTITUTE(TRIM(C2:H2),".",""),",",""),TRIM(CountryList),0)),0)))

I would add UK and USA to your list.

I've tried entering the formula this morning and it works well. The only thing I've noticed is that if, for example, the entry in the address fields is 'GREECE.' and the entry in the CountryList is 'GREECE', it enters 'GREECE.' in the new Country column. I would prefer the entry to be exactly the same as in the CountryList, to avoid duplication. Any ideas?

EDIT: I've just copied the formulas as values to a new column and removed any periods or commas with Edit/Replace.
 
Last edited:
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Just one thing- where do these stray spaces come from? I'm pretty certain that when I created the list I didn't enter a space after the country.

Is it just something you get into the habit of (using the TRIM formula) whenever you create a list like this?

I can't say, it does seem odd. But no, TRIM is an exceptiuon function in my mind, not a standard use one.

Is the following question now redundant?
 
Upvote 0
Yes, the following question was sorted easily enough by edit/replace- let's not over-complicate things!

I think the stray spaces may have appeared because I copied the list from the web. Anyway, I now know how to deal with it in future. Many thanks again for your help.
 
Upvote 0

Forum statistics

Threads
1,215,003
Messages
6,122,655
Members
449,091
Latest member
peppernaut

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