View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike[_31_] Mike[_31_] is offline
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



.

.