Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default ISO 3166 compliant countries

Hi, I receive dozens of address lists from customers. The customers
use a templated excel workbook that has a set array of address fields.
One of these fields is "Country".

Sometimes there are errors in the country names and I need them to be
ISO compliant. Ideally, I'd like to set up a workbook that contains a
list of country codes and a macro workbook that

1. works on the already open address list workbook
2. Checks that the address list workbook has the value in Range("A10")
= "Country"
3. Check all entires in column 10 are within the ISO list, If not, it
highlights those that are not compliant.

As an added extra, it would check for certain commom "errors" and
correct them (e.g. change UK to UNITED KINGDOM).

I've been tying myself in knots trying to use the
worksheetfuntion.countif() function to count if each cell in column 10
is contained in the ISO list. I can't get it to work. Any help is
greatly appreciated!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default ISO 3166 compliant countries

countif only works if the referenced workbook is open

Assumes the ISO list is in the first sheet in the tab order in column A of a
workbook named ISOList.xls found in C:\Myfiles directory. Adjust to suit.

sub MarkTheActivesheet()
Dim sh as Worksheet, bk as Workbook
Dim rng as Range, rng1 as Range
dim cell as Range
Set sh = Activesheet
On Error Resume Next
set bk = Workbooks("ISOList.xls")
On error goto 0
if bk is nothing then
set bk = Workbooks.Open("C:\MyFiles\ISOList.xls")
end if
set rng1 = bk.worksheets(1).columns(1)
set rng = sh.Range(sh.Cells(2,10),sh.cells(rows.count,10).En d(xlup))
rng.Interior.colorIndex = xlNone
for each cell in rng
if application.countif(rng1,cell) = 0 then
cell.Interior.ColorIndex = 3
end if
Next
End sub

Code is untested and may contain typos which you should correct of course.

--
Regards,
Tom Ogilvy


"slug" wrote:

Hi, I receive dozens of address lists from customers. The customers
use a templated excel workbook that has a set array of address fields.
One of these fields is "Country".

Sometimes there are errors in the country names and I need them to be
ISO compliant. Ideally, I'd like to set up a workbook that contains a
list of country codes and a macro workbook that

1. works on the already open address list workbook
2. Checks that the address list workbook has the value in Range("A10")
= "Country"
3. Check all entires in column 10 are within the ISO list, If not, it
highlights those that are not compliant.

As an added extra, it would check for certain commom "errors" and
correct them (e.g. change UK to UNITED KINGDOM).

I've been tying myself in knots trying to use the
worksheetfuntion.countif() function to count if each cell in column 10
is contained in the ISO list. I can't get it to work. Any help is
greatly appreciated!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default ISO 3166 compliant countries

Wow. This works. Thank you so much for your help.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colorizing countries Babymech Excel Discussion (Misc queries) 0 June 5th 09 11:13 PM
VICS compliant BOL template for Excel? Rono Excel Discussion (Misc queries) 0 June 22nd 06 03:49 AM
world countries zaifi Excel Discussion (Misc queries) 1 October 12th 05 09:17 AM
Will the Excel WEEKNUM function become ISO 8601 compliant? Gilles Moerdijk Excel Worksheet Functions 3 February 8th 05 07:05 PM
VBA in other countries uecem[_2_] Excel Programming 0 October 11th 04 08:48 AM


All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"