+ Reply to Thread
Results 1 to 6 of 6

leading zero problem

  1. #1
    Registered User
    Join Date
    09-05-2008
    Location
    London, UK
    Posts
    17

    leading zero problem

    I've searched the forum, because I'm sure that this is a frequent problem. But it seems that all the answers are specific to their problems.

    Anyways, I have column with most as 5 digits, but the one's that started with a "0" were left off. I don't have the original file anymore to copy and paste again, but I have since changed the column to text.

    Can someone help me, to construct a formula if there are only 4 charactes then add a zero in front.

    Thanks.

  2. #2
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    =RIGHT("0"&A1,5)

    Richard
    Richard Schollar
    Microsoft MVP - Excel

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Just a thought, if there is a chance ANY of those numbers are less than 4, this would insure you always get 5 characters, no matter what:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524
    Try A custom format
    Select a range to format, right click with mouse and select format cells=>number=>custom in the type box enter ....
    00000
    Then OK
    So now when ever you have less than 5 digits, the number will be lead with zeros.
    It will also work if you select special=>zip code in the same tab

  5. #5
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717
    Select The column

    Right Click and Select Format Cell

    Select Custom and in the Type: Box enter - '@'

  6. #6
    Registered User
    Join Date
    09-05-2008
    Location
    London, UK
    Posts
    17
    Great, the format cells, custom thing worked perfectly. I saw that solution in an old thread, but I didn't do it properly, your explanation was better.

    Thanks.

+ 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