+ Reply to Thread
Results 1 to 5 of 5

If cell is < 7 digits add 0's in front of number

  1. #1
    Registered User
    Join Date
    10-08-2013
    Location
    United States
    MS-Off Ver
    excel 2010
    Posts
    2

    If cell is < 7 digits add 0's in front of number

    Hi,

    I need an formula that will be something like 'If cell is < 7 digits add 0's in front of number'

    Right now in cell - after formula should be:

    123456 - 0123456
    1234567 - 1234567
    123456 - 0123456
    12345678 - 12345678

    Can someone please help me?

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

    Re: If cell is < 7 digits add 0's in front of number

    use

    =TEXT(A1,"0000000")
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,956

    Re: If cell is < 7 digits add 0's in front of number

    Hi and welcome to the forum

    If you dont want to add any other formulas or columns, you could use a custom format to force the leading zero

    highlight the range/right-click/format/number/custom enter 7 zeros
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    10-08-2013
    Location
    United States
    MS-Off Ver
    excel 2010
    Posts
    2

    Re: If cell is < 7 digits add 0's in front of number

    =TEXT(A1,"0000000") worked great!


    Thanks!

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,956

    Re: If cell is < 7 digits add 0's in front of number

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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. Validate cell and force digits in front
    By jpruffle in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-04-2014, 09:39 AM
  2. Replies: 5
    Last Post: 12-08-2008, 11:47 AM
  3. how to add a letter in front of each number in a cell
    By nmodafferi in forum Excel General
    Replies: 15
    Last Post: 06-16-2005, 04:05 PM
  4. [SOLVED] 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. [SOLVED] Using a IF formula, I would like to drop the 2 digits in front of.
    By osuhoosier in forum Excel General
    Replies: 3
    Last Post: 01-06-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