+ Reply to Thread
Results 1 to 5 of 5

Keeping Leading Zeros

  1. #1
    Registered User
    Join Date
    07-09-2008
    Location
    Panama City, FL
    MS-Off Ver
    2007
    Posts
    42

    Keeping Leading Zeros

    I have a sheet that I am copying data from to get it in a different format, and the sheet that I am copying from has some data in the form 09, 05, etc. However, when I copy it over, it automatically removes the leading zero. I have tried putting the value in a variable declared as a string, but that doesn't work, either. Any ideas?

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Quote Originally Posted by teddybouch
    I have a sheet that I am copying data from to get it in a different format, and the sheet that I am copying from has some data in the form 09, 05, etc. However, when I copy it over, it automatically removes the leading zero. I have tried putting the value in a variable declared as a string, but that doesn't work, either. Any ideas?
    Yep,
    this question has been answered many times on this forum. have a look at " custom format" using 00####

    Cheers

  3. #3
    Registered User
    Join Date
    07-09-2008
    Location
    Panama City, FL
    MS-Off Ver
    2007
    Posts
    42
    Yeah, I searched for this before I posted the question and found the answers you are referring to. The problem is that the column does not always contain an entry that starts with a zero. It could also be all letters like ER, or a misture like 5C. Therefore, I can't simply format the column to have this custom format. In addition, the entries won't always be in the same place, so I can't go through and format specific cells, either. Even if they were, that would be infeasible because there are over 14,000 entries. Any suggestions?

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Does this help

    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Registered User
    Join Date
    07-09-2008
    Location
    Panama City, FL
    MS-Off Ver
    2007
    Posts
    42
    Actually, I was able to solve my problem by formatting all the target cells as text. I was hoping for a non-code solution if I could avoid it - it's already getting a little long. However, the data later gets read into textboxes using a simple assignment:

    Please Login or Register  to view this content.
    Here it cuts off the zero again. Is there a way to tell the textbox to take it as a string rather than a number?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1