Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Len(ZipCode)

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Len(ZipCode)

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

"Rafi" wrote:

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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Len(ZipCode)

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

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

--
Rick (MVP - Excel)


"Rafi" wrote in message
...
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?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Len(ZipCode)

It is one of the cell format choices under the Special category.

--
Rick (MVP - Excel)


"Mike H" wrote in message
...
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

"Rafi" wrote:

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?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Len(ZipCode)

Rick,

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

Mike

"Rick Rothstein" wrote:

It is one of the cell format choices under the Special category.

--
Rick (MVP - Excel)


"Mike H" wrote in message
...
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

"Rafi" wrote:

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?





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Len(ZipCode)

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

"Rick Rothstein" wrote:

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

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

--
Rick (MVP - Excel)


"Rafi" wrote in message
...
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?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to insert a 0 in front of zipcode hlander9 Excel Discussion (Misc queries) 2 January 12th 10 11:01 PM
Counting by Zipcode and other criteria Perkgolf Excel Discussion (Misc queries) 3 April 8th 07 04:00 AM
zipcode, enter 5, show 3 JcR Excel Worksheet Functions 4 March 14th 06 06:21 PM
how do I enter a zipcode starting with a 0 Bea VanKampen Excel Discussion (Misc queries) 2 May 25th 05 12:02 AM
How to check a zipcode hans[_2_] Excel Programming 4 July 24th 03 04:55 PM


All times are GMT +1. The time now is 01:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"