ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to check a zipcode (https://www.excelbanter.com/excel-programming/272534-how-check-zipcode.html)

hans[_2_]

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




Nick

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



.


Mike[_31_]

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



.


Mike[_31_]

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



.

.


Mike Waldron

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



.

.



All times are GMT +1. The time now is 10:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com