Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to check a zipcode

I want to check if a zipcode is correct.
In the netherlands the first 4 characters of a zipcode are numbers
the next to characters are characters.
How can i test if this is the case.
I want to do this in vba and use excel 2002

Greetings hans



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default How to check a zipcode


Can you not just use validation? - go to data and choose
validation.

-----Original Message-----
I want to check if a zipcode is correct.
In the netherlands the first 4 characters of a zipcode

are numbers
the next to characters are characters.
How can i test if this is the case.
I want to do this in vba and use excel 2002

Greetings hans



.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default How to check a zipcode

This will return true if the first four characters are
numerical, and the 5th and 6th are between A and Z (not
case sensitive).

IsValidZip = Isnumeric(Left(Zip,4)) AND IIf(Asc(UCase(Mid
(Zip, 5, 1))) 64 And Asc(UCase(Mid(Zip, 5, 1)) < 91),
True, False) AND
IIf(Asc(UCase(Mid(Zip, 6, 1))) 64 And Asc(UCase(Mid(Zip,
6, 1)) < 91), True, False)


-----Original Message-----
I want to check if a zipcode is correct.
In the netherlands the first 4 characters of a zipcode

are numbers
the next to characters are characters.
How can i test if this is the case.
I want to do this in vba and use excel 2002

Greetings hans



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default How to check a zipcode

Eeep. I should have also put a test to ensure the length
is 6 characters prior to evaluating the rest.

IsValidZip = False
If Len(Zip) = 6 Then
IsValidZip = {all that stuff below}
End If


-----Original Message-----
This will return true if the first four characters are
numerical, and the 5th and 6th are between A and Z (not
case sensitive).

IsValidZip = Isnumeric(Left(Zip,4)) AND IIf(Asc(UCase(Mid
(Zip, 5, 1))) 64 And Asc(UCase(Mid(Zip, 5, 1)) < 91),
True, False) AND
IIf(Asc(UCase(Mid(Zip, 6, 1))) 64 And Asc(UCase(Mid

(Zip,
6, 1)) < 91), True, False)


-----Original Message-----
I want to check if a zipcode is correct.
In the netherlands the first 4 characters of a zipcode

are numbers
the next to characters are characters.
How can i test if this is the case.
I want to do this in vba and use excel 2002

Greetings hans



.

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How to check a zipcode

if isnumber(mid(zipcode,1,4)) and istext(zipcode,5,2)then
check = "true"
else
check = "false"
end if

The mid function parses the zip code while isnumber and
istext check the appropriate part of the zipcode to see if
it is valid. You can find an explanation of the mid
function in the VB help.
-----Original Message-----

Can you not just use validation? - go to data and choose
validation.

-----Original Message-----
I want to check if a zipcode is correct.
In the netherlands the first 4 characters of a zipcode

are numbers
the next to characters are characters.
How can i test if this is the case.
I want to do this in vba and use excel 2002

Greetings hans



.

.

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
trying to insert a 0 in front of zipcode hlander9 Excel Discussion (Misc queries) 2 January 12th 10 11:01 PM
Counting by Zipcode and other criteria Perkgolf Excel Discussion (Misc queries) 3 April 8th 07 04:00 AM
zipcode, enter 5, show 3 JcR Excel Discussion (Misc queries) 2 March 14th 06 06:30 PM
zipcode, enter 5, show 3 JcR Excel Worksheet Functions 4 March 14th 06 06:21 PM
how do I enter a zipcode starting with a 0 Bea VanKampen Excel Discussion (Misc queries) 2 May 25th 05 12:02 AM


All times are GMT +1. The time now is 06:54 AM.

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"