+ Reply to Thread
Results 1 to 9 of 9

Custom cell format with trailing zeros

  1. #1
    Registered User
    Join Date
    05-30-2014
    Posts
    4

    Question Custom cell format with trailing zeros

    Hi,

    I'm hoping to apply custom formatting to cells but I require trailing zeros (instead of applying the formatting by reading the number left to right and add leading zeros, it would apply right to left with trailing zeros).

    Eg. Desired format: 00-00-0000-0000-0000-000

    If 01-29-5512-8844 is entered, I would want this to appear as: 01-29-5512-8844-0000-000. Instead the custom number format gives me 00-00-0000-1295-5128-844

    Any way I change leading zeros to trailing zeros?

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Custom cell format with trailing zeros

    Please post more examples that show the kinds of patterns you need to accommodate.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Custom cell format with trailing zeros

    Hi kdjd,

    Try the following custom format:
    Please Login or Register  to view this content.
    Formatting before the first semi-colon is for positive numbers
    Formatting after the first semi-colon is for negative numbers
    Formatting after the second semi-colon is for zero values
    Formatting after the 3rd semi-colon is for text

    Lewis

  4. #4
    Registered User
    Join Date
    05-30-2014
    Posts
    4

    Re: Custom cell format with trailing zeros

    Thanks, Ron, here are some more examples:

    If I enter:
    023722015046, would want this to appear as: 02-37-2201-5046-0000-000
    0237220150465004677, would want this to appear as: 02-37-2201-5046-5004-677
    0237220150465004, would want this to appear as: 02-37-2201-5046-5004-000

    Basically, regardless of how many numbers are entered (maximum of 19), I'd like the segments filled with zeros at the backend.

    Thanks very much for your reply, Lewis, I should have used more examples as it won't always be 0000-000 that will need to entered at the end, it will depend on how many numbers are entered to start with.

    Thank again!

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Custom cell format with trailing zeros

    With your source text in A1
    this regular formula converts it to the format you want
    Please Login or Register  to view this content.
    EDITED TO INCLUDE THIS COMMENT (05/31/2014):
    Well, color me surprised! I didn't remember that the TEXT function coerces numeric text into numbers.
    Consequently, the double-minus is unnecessary in the above formula and this works:
    Please Login or Register  to view this content.
    Is that something you can work with?
    Last edited by Ron Coderre; 05-31-2014 at 09:55 AM.

  6. #6
    Registered User
    Join Date
    05-30-2014
    Posts
    4

    Re: Custom cell format with trailing zeros

    That's a beautiful formula, Ron! Thank you! And it works perfectly. But just confirming there is no way to get this format when the entry is made in the cell, it needs to be converted to the correct format by a formula in another cell?

    Thanks again, your help is greatly appreciated.

  7. #7
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Custom cell format with trailing zeros

    Excel can only handle up to 15 significant digits.

    If you type this 19 digit number into a cell: 1234567890123456789
    and press ENTER, it will convert to this: 1234567890123450000

    Your "numbers" can have up to 19 significant digits. Consequently, they must be converted to text.

  8. #8
    Registered User
    Join Date
    05-30-2014
    Posts
    4

    Re: Custom cell format with trailing zeros

    Gotcha. Thanks very much, Ron, greatly appreciated.

  9. #9
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Custom cell format with trailing zeros

    Glad I could help

    Be sure to mark this thread as SOLVED (from the Thread Tools menu)

+ 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. Custom Number Format with Leading Zeros (Greek)
    By Graham1 in forum Excel General
    Replies: 5
    Last Post: 01-22-2020, 11:30 PM
  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] Add Trailing Zeros
    By sweetkel23 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 12-07-2012, 01:42 AM
  4. Replies: 5
    Last Post: 04-09-2012, 02:28 PM
  5. trailing zeros in formula bar for numeric cell
    By rmagers in forum Excel General
    Replies: 4
    Last Post: 01-25-2010, 06:38 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