+ Reply to Thread
Results 1 to 8 of 8

Formatting a Number with leading zeros

  1. #1
    Registered User
    Join Date
    08-23-2007
    Posts
    30

    Formatting a Number with leading zeros

    I have a column in Excel with numeric values such as:

    11405
    11490
    11516
    11859

    I need a way to convert to a 20 digit number (add 15 leading zeros)......

    00000000000000011405

    I'm certain there's an easy way for this..........

    Thanks in advance.......

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Formatting a Number with leading zeros

    Try a custom number format

    Format Cells;> Number-> Custom

    then add a Format with twenty zeros i.e. 00000000000000000000
    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 Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Formatting a Number with leading zeros

    Like this perhaps?

    Select column and right-click one of the highlighted cells, and then click "Format Cells."

    Click the "Number" tab, and then click "Custom" on the left side of the "Format Cells" window.

    Click the number "0" under "Type," and then type the number of zeros indicating the maximum number of digits that you plan to enter for a single item in your spreadsheet. For example, type "00000" if you would like each number to be five digits long.

    If you type the number "123," Excel will add leading zeroes to make the number "00123."
    Click "OK" to save the custom format.
    Alf

  4. #4
    Registered User
    Join Date
    08-23-2007
    Posts
    30

    Re: Formatting a Number with leading zeros

    Thanks for the quick response. Unfortunately, I don't think this will work for me..........

    The cell displays 00000000000000011405.............but when I highlight the cell.........11405 is the value.

    This excel file will be used to import transactions into an accounting package. I know from expereince my integration tool will not 'see' the 0000000000000000 leading zeros and will import a value of 11405.

    I tried converting to 'text' but, of course it doesn't stay numeric - leading zeros go away.

    I think I need to format the cell as a string and then programatically add the 15 leading zeros (leading zeros is always 15)......

    Any other thoughts?

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,598

    Re: Formatting a Number with leading zeros

    Try ="000000000000000"&A1

  6. #6
    Registered User
    Join Date
    08-23-2007
    Posts
    30

    Re: Formatting a Number with leading zeros

    Actually I just solved my problem.

    I copied the values of the custom formatted numbers (suggested by Alf) into notepad. Notepad picked up the leading zeros. I then copied back into a row formatted as 'text' and the leading zeros copied over nicely.......

    Probably not eloquent.but it worked..........thanks to Alf for his assistance

  7. #7
    Registered User
    Join Date
    08-23-2007
    Posts
    30

    Re: Formatting a Number with leading zeros

    I tested Pepe's solution - also works quite nicely.........Thanks

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Formatting a Number with leading zeros

    Maybe with your number in A2 down
    In B2
    Please Login or Register  to view this content.
    Drag/Fill Down

    Then Copy the result and Paste Special > Values to A2 if you need to. Delete B2 Down.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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