Validate format of values

M

maryj

Client is using WinXP/Office 2003.
He has cells with Canadian postal codes. The postal codes should be 6
characters starting with a letter and then alternating every other with a
number. For example, V2L3M4. He would like a formula to evaluate the cell to
determine if the postal code follows the correct syntax. Any ideas?
 
P

Per Erik Midtrød

Hello Maryj.

If your zip code is in A1 you could use this formula:
=AND(ISNUMBER(LEFT(A1))=FALSE;ISNUMBER(MID($A1;2;1)*1);ISNUMBER(MID($A1;3;1)*1)=FALSE;ISNUMBER(MID($A1;4;1)*1);ISNUMBER(MID($A1;5;1)*1)=FALSE;ISNUMBER(MID($A1;6;1)*1);LEN(A1=6)
)

It checks each digit to determine whether it is text or number.

Per Erik
 
M

maryj

Thanks! Perfect!
--
maryj


Per Erik Midtrød said:
Hello Maryj.

If your zip code is in A1 you could use this formula:
=AND(ISNUMBER(LEFT(A1))=FALSE;ISNUMBER(MID($A1;2;1)*1);ISNUMBER(MID($A1;3;1)*1)=FALSE;ISNUMBER(MID($A1;4;1)*1);ISNUMBER(MID($A1;5;1)*1)=FALSE;ISNUMBER(MID($A1;6;1)*1);LEN(A1=6)
)

It checks each digit to determine whether it is text or number.

Per Erik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top