+ Reply to Thread
Results 1 to 4 of 4

Number formatting problem

Hybrid View

  1. #1
    Registered User
    Join Date
    05-22-2013
    Location
    Illinois
    MS-Off Ver
    Excel 2007
    Posts
    17

    Number formatting problem

    I'm having trouble formatting numbers that I copy from another document.

    For example, If i copy a number like this 636-10-14, I would like it to appear as 0636-10-14. I want to add leading zeros to fill a form of xxxx-xx-xx.

    I tried doing the normal formatting -> numbers -> custom but it didn't work. I figure it didn't work because the '-' and the fact that they are copied.

    Any suggestions would be greatly appreciated!

  2. #2
    Forum Contributor
    Join Date
    12-11-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    232

    Re: Number formatting problem

    In the colum next to your copied cells paste this and drag down

    =LEFT(0&A1,LEN(A1)+1)

  3. #3
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: Number formatting problem

    If some of your numbers are already in the proper xxxx-xx-xx format, then nemo74's elegant little formula will also give these numbers an extra 0... which you might not want.

    If so, then you might want to use this formula:

    =IF(LEN(A1)=9,0&A1, A1)

    This adds an IF check to his code, to first check to see if the length is 9. If so, it adds a zero, otherwise it leaves the number alone.

  4. #4
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Number formatting problem

    Hi lulu319

    Or another way, this will convert it to a number.
    Formula: copy to clipboard
    =--SUBSTITUTE(A1,"-","")

    Then format the cells as: 0000"-"00"-"00
    Last edited by Kevin UK; 05-24-2013 at 06:42 PM.
    Regards Kevin


    Merged Cells (They are the work of the devil!!!)

+ 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