Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Zip Code Formatting


Hi All,

I receive a monthly excel spreadsheet that contains zip codes in
different formats. I'm assigning sales reps to each zip code. I ran
into difficulty because this file contains both US zips (need first 5
#s of the string) and Canadian zips, which is a mix of text and numbers
but always begins with a letter (e.g. "V5T 4T5").

I'm not sure how to differentiate between #s and letters.

Could someone help me:
1. Format the cells that begin with a number to be the first 5
characters only.
2. Don't edit the cells that begin with letters
3. Assign cells that begin with letters as "Canada" in Cells(x,9)

My code is as follows:

Sub RepAssignment ()
x = 2
y = 9

Do While Cells(x,8).Value < ""
If (Cells(x,8).Value 0) and (Cells(x,8).Value <=999) Then Cells(x,9) =
"LH"
If (Cells(x,8).Value 1000) and (Cells(x,8).Value <=2799) Then
Cells(x,9) = "LS"
...etc...
If (Cells(x,8).Value =99500) and (Cells(x,8).Value <= 99999) Then
Cells(x,9) = "H"
x = x + 1
Loop

End Sub


Thanks for your help in advance,
Christine


--
weeshie73
------------------------------------------------------------------------
weeshie73's Profile: http://www.excelforum.com/member.php...o&userid=24792
View this thread: http://www.excelforum.com/showthread...hreadid=536473

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Zip Code Formatting

if isnumeric(left(cells(x,8).value,1)) then
' US Zip

else
' Canadian Zip

end if

--
Regards,
Tom Ogilvy


"weeshie73" wrote:


Hi All,

I receive a monthly excel spreadsheet that contains zip codes in
different formats. I'm assigning sales reps to each zip code. I ran
into difficulty because this file contains both US zips (need first 5
#s of the string) and Canadian zips, which is a mix of text and numbers
but always begins with a letter (e.g. "V5T 4T5").

I'm not sure how to differentiate between #s and letters.

Could someone help me:
1. Format the cells that begin with a number to be the first 5
characters only.
2. Don't edit the cells that begin with letters
3. Assign cells that begin with letters as "Canada" in Cells(x,9)

My code is as follows:

Sub RepAssignment ()
x = 2
y = 9

Do While Cells(x,8).Value < ""
If (Cells(x,8).Value 0) and (Cells(x,8).Value <=999) Then Cells(x,9) =
"LH"
If (Cells(x,8).Value 1000) and (Cells(x,8).Value <=2799) Then
Cells(x,9) = "LS"
...etc...
If (Cells(x,8).Value =99500) and (Cells(x,8).Value <= 99999) Then
Cells(x,9) = "H"
x = x + 1
Loop

End Sub


Thanks for your help in advance,
Christine


--
weeshie73
------------------------------------------------------------------------
weeshie73's Profile: http://www.excelforum.com/member.php...o&userid=24792
View this thread: http://www.excelforum.com/showthread...hreadid=536473


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
Zip Code Formatting JWCrosby New Users to Excel 8 July 1st 06 11:17 AM
zip code formatting MLD Excel Discussion (Misc queries) 1 August 19th 05 04:00 PM
Conditonal Formatting VB Code? RonS Excel Programming 4 January 16th 04 03:06 PM
Add Formatting Code in Macro Phil Hageman[_3_] Excel Programming 1 November 10th 03 02:13 PM
Code to maintain formatting Mel[_7_] Excel Programming 1 August 14th 03 04:54 PM


All times are GMT +1. The time now is 09:01 PM.

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

About Us

"It's about Microsoft Excel"