+ Reply to Thread
Results 1 to 9 of 9

Retaining leading zeros

  1. #1
    Registered User
    Join Date
    07-03-2007
    Location
    Canberra, Australia
    MS-Off Ver
    2010
    Posts
    60

    Retaining leading zeros

    Hi All,

    I need help stopping excel removing leading zero's from a range of numbers I have on a worksheet, I have searched this and other forums and am unable to find a solution. The problem is I have a range of Alphanumeric characters which I need to increment. (Please see attached) the problem is I need to remove the character to increment the numbers.
    This is the code I have so far
    Please Login or Register  to view this content.
    unfortunately when I am left with only the number excel removes the leading zeros.

    Any help would be much appreciated
    Attached Images Attached Images
    Kerno

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Create a Custom NumberFormat such as "00000" which will display 123 as 00123
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    Please Login or Register  to view this content.
    Last edited by jindon; 11-21-2007 at 03:52 AM.

  4. #4
    Registered User
    Join Date
    07-03-2007
    Location
    Canberra, Australia
    MS-Off Ver
    2010
    Posts
    60
    Hi royUK,

    I have tried the custom number format via the Format Cells option, the problem is the code actually removes the zeros before it is sent to the spreadsheet

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Quote Originally Posted by Kerno
    Hi royUK,

    I have tried the custom number format via the Format Cells option, the problem is the code actually removes the zeros before it is sent to the spreadsheet
    Try adding the format in the code.

  6. #6
    Registered User
    Join Date
    07-03-2007
    Location
    Canberra, Australia
    MS-Off Ver
    2010
    Posts
    60
    Hi jindon,

    Thanks for the code, the problem is it does not increment to the next number whenever it finds an "A", "T" or P" in column A as in
    A A0124
    A A0125
    T T0125
    P P0126
    P P0127

    the reference cells will always be B3, B4 and B5 which is downloaded from a database, this is what is already in the database so I need the next incremented numbers created.

    Hope this make sense

  7. #7
    Registered User
    Join Date
    07-03-2007
    Location
    Canberra, Australia
    MS-Off Ver
    2010
    Posts
    60
    Hi royUK,

    Could you please show me what you mean, I have tried a variety of formats but it seams to makes no difference.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Last edited by jindon; 11-21-2007 at 04:34 AM.

  9. #9
    Registered User
    Join Date
    07-03-2007
    Location
    Canberra, Australia
    MS-Off Ver
    2010
    Posts
    60
    Thanks jindon works great

+ 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