Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Leading Zeros

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Posts
    86
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I currently import a csv file. One of the columns contains some numbers that have four leading zeros and also some numbers that have a leading alphabetic character. When the csv is imported it drops the leading zeros. If I use the custom format it adds zeros to everything in the column. Is there any way to add zeros back to a cell containing less than 6 characters?

    TIA

  2. #2
    New Member
    Join Date
    Mar 2002
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    There's a couple of ways:

    Firstly when you go through the import wizard you will have an opportunity to tell the wizard the kind of cell you are importing, at this stage you change it from "General" to "Text". That way you keep all leading Zeros on the columns you selected.

    The second way is by using "0" instead of "#" in the custom mode of formating cells.

    Mark

  3. #3
    MrExcel MVP Aladin Akyurek's Avatar
    Join Date
    Feb 2002
    Location
    The Hague, NL
    Posts
    84,026
    Post Thanks / Like
    Mentioned
    37 Post(s)
    Tagged
    7 Thread(s)

    Default

    On 2002-04-11 01:13, rexel12 wrote:
    I currently import a csv file. One of the columns contains some numbers that have four leading zeros and also some numbers that have a leading alphabetic character. When the csv is imported it drops the leading zeros. If I use the custom format it adds zeros to everything in the column. Is there any way to add zeros back to a cell containing less than 6 characters?

    TIA
    Use

    =RIGHT(REPT("0",6-LEN(A1))&A1,6)

    if multiple leading zeroes are missing or

    =RIGHT(0&A1,6)

    if just a single leading zero is missing.


  4. #4
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Austin, Texas USA
    Posts
    11,654
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-11 01:13, rexel12 wrote:
    I currently import a csv file. One of the columns contains some numbers that have four leading zeros and also some numbers that have a leading alphabetic character. When the csv is imported it drops the leading zeros. If I use the custom format it adds zeros to everything in the column. Is there any way to add zeros back to a cell containing less than 6 characters?

    TIA
    Change the file extension to .txt and use the Text to Columns wizard.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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