+ Reply to Thread
Results 1 to 4 of 4

Adding 0's in front of string to equal a fixed number of characters

  1. #1
    Registered User
    Join Date
    10-22-2008
    Location
    US
    Posts
    15

    Adding 0's in front of string to equal a fixed number of characters

    Hi:

    I have numerous cells that have to be 18 characters in length. Each cell has characters that currently could be 8 in one cell and 12 in another. Is there a forumla that I can add 0's in front so that in total the cell is 18 characters long?

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Adding 0's in front of string to equal a fixed number of characters

    Try:

    =TEXT(A1,REPT(0,18))
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

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

    Re: Adding 0's in front of string to equal a fixed number of characters

    If the cell is a number, NBVC's answer will work. If it's a string, try

    =REPT("0", 18-LEN(A1))&A1
    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
    Registered User
    Join Date
    10-22-2008
    Location
    US
    Posts
    15

    Re: Adding 0's in front of string to equal a fixed number of characters

    That worked and thanks for the quick response

+ 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