+ Reply to Thread
Results 1 to 7 of 7

fixing numbers without losing zeros

  1. #1
    Forum Contributor
    Join Date
    03-12-2014
    Location
    Michigan, USA
    MS-Off Ver
    Excel 2016
    Posts
    146

    fixing numbers without losing zeros

    I have a spreadsheet that has numbers in the format of:

    0001-1234
    0258-6847
    1658-5487 etc.

    Some one has messed up the spreadsheet and now some of the numbers look like:

    000112-34
    025868-47
    165854-87 etc

    I need to get the numbers back to their original state. any ideas? some of the things I tried ended up with the number losing the zeros at the beginning.

  2. #2
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: fixing numbers without losing zeros

    Are they numbers, or text that looks like numbers?

    If they are numbers, change the formatting to 0000-0000.

    If they are text try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Please add reputation by clicking on the * if I have helped.
    Please mark the thread SOLVED if your issue has been resolved.
    Thanks, Glenn.

  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,942

    Re: fixing numbers without losing zeros

    Try this in a helper column, copied down...
    =LEFT(A1,4)&"-"&MID(SUBSTITUTE(A1,"-",""),5,99)

    If you want to, you can then copy/paste values back onto the original data, then delete the helper
    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
    Forum Contributor
    Join Date
    03-12-2014
    Location
    Michigan, USA
    MS-Off Ver
    Excel 2016
    Posts
    146

    Re: fixing numbers without losing zeros

    how would I change the formatting to 0000-0000? I assume that would change a cell from 025868-47 to 0258-6847?

  5. #5
    Forum Contributor
    Join Date
    03-12-2014
    Location
    Michigan, USA
    MS-Off Ver
    Excel 2016
    Posts
    146

    Re: fixing numbers without losing zeros

    and they are mostly numbers, however, eventually some will be like:

    0124-4FDT

  6. #6
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: fixing numbers without losing zeros

    If some of them have alphabetical characters in them, not just numerical, use Ford's or my formula and then copy the values back onto the original data as Ford suggested. The formatting option won't work as they are not numbers.

    If the number was entered as 2586847 (from your example in post #4) then you could set the number format to 0000-0000 (right click the cell, then on Format Cells, select the Number tab then select Custom and type 0000-0000 in the box under Type: ). The number would then appear as 0258-6847 in the cell, but still be a number that Excel could perform numerical functions on/with. If somebody had changed that formatting to 000000-00 the number would appear as 025868-47. It appears as though your data is not like that though, and the string is entered with the "-" included. Excel therefore treats it as text.

  7. #7
    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,942

    Re: fixing numbers without losing zeros

    The formula suggested by Gak and myself will take the 1st 4 characters (number or test, doesnt matter), then insert "-" and finally remove any extra "-" and insert what is left.

    No formatting needed, it will be treated as text, and it will handle any numeric/text combo

+ 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] Fixing Random Numbers
    By PomDave in forum Excel General
    Replies: 4
    Last Post: 10-27-2013, 02:26 AM
  2. Copy custom format without losing leading zeros
    By ucyzgba in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-14-2013, 09:47 AM
  3. [SOLVED] Losing Leading Zeros
    By timbo1957 in forum Excel General
    Replies: 7
    Last Post: 07-27-2012, 09:25 AM
  4. Replies: 0
    Last Post: 08-11-2011, 12:47 AM
  5. Merging cells without losing zeros
    By mrwd40 in forum Excel General
    Replies: 2
    Last Post: 01-29-2010, 04:52 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