+ Reply to Thread
Results 1 to 6 of 6

Add leading zeroes to number, number formatting

  1. #1
    Registered User
    Join Date
    01-21-2015
    Location
    California, USA
    MS-Off Ver
    2013
    Posts
    35

    Add leading zeroes to number, number formatting

    Hi all,

    I've assigned a number value to a variable called x. This number goes from 1-105 but I would like the number to be displayed such that...

    1 = 001
    5 = 005
    10 = 010
    50 = 050
    100 = 100
    101 = 101

    I think if I do a length counter I can probably get this done by manually adding the 0, does anyone have a cleaner way of getting this done?

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Add leading zeroes to number, number formatting

    custom format the column with 000
    Ben Van Johnson

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Add leading zeroes to number, number formatting

    Try
    E5 = your value
    Somewhere = REPT("0",3-LEN(E5)) & E5
    - Battle without fear gives no glory - Just try

  4. #4
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Add leading zeroes to number, number formatting

    Hi,

    I haven't tried this, but if you want to set it in code, I think this should work [/fingers crossed]
    Please Login or Register  to view this content.
    Regards,
    Aardigspook

    If your problem is solved, please go to 'Thread Tools' on your first post and 'Mark Thread as Solved'.
    You don't need to give me rep if I helped, but thanks are appreciated.

  5. #5
    Registered User
    Join Date
    01-21-2015
    Location
    California, USA
    MS-Off Ver
    2013
    Posts
    35

    Re: Add leading zeroes to number, number formatting

    thanks everyone! all of the suggestions were very helpful.

  6. #6
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Add leading zeroes to number, number formatting

    You're welcome and thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 10-10-2012, 06:04 AM
  2. Add zeroes within dates (NOT leading zeroes)
    By anthony19 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2012, 04:08 PM
  3. Add a preset number of cells after unknown number of leading zeroes
    By Marweas in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-24-2012, 09:23 PM
  4. Formatting a Number with leading zeros
    By btamulis in forum Excel General
    Replies: 7
    Last Post: 02-11-2012, 12:09 PM
  5. (SOLVED) Help with leading zero and number formatting
    By newbie454 in forum Excel General
    Replies: 7
    Last Post: 12-13-2011, 06:37 AM
  6. Extracting digits from a number with leading zeroes
    By jomaule in forum Excel General
    Replies: 11
    Last Post: 06-02-2009, 07:50 AM
  7. Replies: 9
    Last Post: 11-25-2008, 08:51 PM
  8. [SOLVED] Leading Zeroes
    By Ken in forum Excel General
    Replies: 1
    Last Post: 10-07-2005, 11:05 AM

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