+ Reply to Thread
Results 1 to 5 of 5

Adding 0 in front of number to complete 4 digits series

  1. #1
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Adding 0 in front of number to complete 4 digits series

    Hi,

    I have a list of numbers with 2, 3, and 4 digits. Is there a formula that can recognize if there are only 2 digits, it will add 2 zeros in front of the number.

    For example,

    47 will become 0047
    234 will become 0234
    1234 will become 1234

  2. #2
    Registered User
    Join Date
    06-01-2012
    Location
    New Orleans, US
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Adding 0 in front of number to complete 4 digits series

    Something like:

    if(len(cell reference)=4,(cell reference),if(len(cell reference)=3,"0"&(cell reference),if(len(cell reference)=2,"00&(cell reference)))))

    cell reference = cell with data

    May work

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Adding 0 in front of number to complete 4 digits series

    you can do Format Cell> Custom> 0000
    which changes the appearance but not the reality (234 is still number 234)
    or in another cell
    =TEXT(A1, "0000"). this changes the value to text with the appropriate zeros.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Adding 0 in front of number to complete 4 digits series

    Hi,

    =TEXT(A1,"0000")

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  5. #5
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Adding 0 in front of number to complete 4 digits series

    Thanks guys! All the tips are very useful!!

+ 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. [SOLVED] Adding zero (o) in front o each number in a column
    By kurtwm in forum Excel General
    Replies: 4
    Last Post: 01-03-2014, 12:56 AM
  2. If cell is < 7 digits add 0's in front of number
    By mrdilsingh in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-08-2013, 11:10 PM
  3. adding a '+' in front of a positive number
    By mike in forum Excel General
    Replies: 1
    Last Post: 06-06-2005, 07:05 PM
  4. adding digits to front/end of fax numbers
    By Luke in forum Excel General
    Replies: 2
    Last Post: 04-27-2005, 07:06 PM
  5. adding a zero in front of number
    By Pinky in forum Excel General
    Replies: 4
    Last Post: 04-07-2005, 05:06 PM

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