Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
trying to insert a 0 in front of zipcode | Excel Discussion (Misc queries) | |||
Counting by Zipcode and other criteria | Excel Discussion (Misc queries) | |||
zipcode, enter 5, show 3 | Excel Discussion (Misc queries) | |||
zipcode, enter 5, show 3 | Excel Worksheet Functions | |||
how do I enter a zipcode starting with a 0 | Excel Discussion (Misc queries) |