+ Reply to Thread
Results 1 to 6 of 6

Leading zeros

  1. #1
    Registered User
    Join Date
    08-23-2012
    Location
    Unites States
    MS-Off Ver
    Excel 2003
    Posts
    2

    Leading zeros

    Thank you taking the time to help!

    I am importing and concatenating long text strings from multiple sources. These are actually numeric data but Excel's limit of 16 numeric characters prevents me from saving them as such. One of the strings that I 'tie' into a longer text value is a ten digit 'number'. This number frequently includes leading zeros but on the source formatted document (not Excel) these zeros are often 'stripped' before the data can be imported to Excel. My goal is to append any imported values less than ten digits in length to 'fill' with leading zeros.

    Desired Value (in text format):
    0123456789

    Currently imported value (in text format)
    123456789

    Is there a function within Excel to do this neatly and conveniently?

    Thank you

  2. #2
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Leading zeros

    =Try..

    =IFERROR(REPT(0,10-LEN(A1))&A1,A1)
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Leading zeros

    this should work,

    =IFERROR(REPT(0,10-LEN(A1))&A1,A1)

    Edit: ace, You beat me to it.
    Regards,
    amotto

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  4. #4
    Registered User
    Join Date
    06-26-2012
    Location
    Krakow, Poland
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Leading zeros

    Hi

    Not sure if i understood correctly, but i would first of all changed the format of cells (where the values are imported) to text - this will prevent excel from autoamtically changing the format. If the value is without leading zeroes, you can simply use &, like ="0" & a1, where a1 is the number without leading zeros.

    Or is your question about how to actually append those numbers one after another?

    Bartek

  5. #5
    Forum Contributor day92's Avatar
    Join Date
    04-20-2010
    Location
    Los Angeles
    MS-Off Ver
    Excel 360
    Posts
    600

    Re: Leading zeros

    You can try..

    =TEXT(A1,"0000000000")

  6. #6
    Registered User
    Join Date
    08-23-2012
    Location
    Unites States
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Leading zeros

    Many Thanks! =IFERROR(REPT(0,10-LEN(A1))&A1,A1) does it in one shot!

+ 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