Len(ZipCode)

R

Rafi

How do you test the length of a zip code starting with zero (e.g. 07580)?
The column in Excel is formatted as Zip and the page correctly displays the
leading zero however, a test of the length returns 4. Is there a way using
VBA to properly test for a zip code whose first digit is a zero?
 
M

Mike H

Rafi,

I've never encountered a format of 'Zip' is it in 2007?

However, if the leading zero is a format then LEN() won't count it. Why
don't you enter your Zip codes with a leading apostrophe ' then len will work.

Mike
 
R

Rick Rothstein

Test the Text property of the cell, not the value property. For example...

MsgBox Len(Range("A1").Text)
 
M

Mike H

Rick,

Thanks for that, it never appears in my 'special' list because I have UK
selected but it's there under US options.

Mike
 
R

Rafi

Rick - Awesome.....This did the trick

Rick Rothstein said:
Test the Text property of the cell, not the value property. For example...

MsgBox Len(Range("A1").Text)
 

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