+ Reply to Thread
Results 1 to 10 of 10

Show decimals until different than zero

  1. #1
    Registered User
    Join Date
    05-21-2021
    Location
    US,UT
    MS-Off Ver
    365
    Posts
    5

    Talking Show decimals until different than zero

    Hello!

    I need a formula/function that can help me show as many decimals needed (0s) until it changes to anything but a 0 and show 2 decimals after that.

    Examples:

    0.0008456 = 0.00084
    0.026584 = 0.026
    0.15 = 0.15
    0.000001 = 0.000001

    I tried different custom formats but so far I've had no luck getting the right one.
    Thought of using an IF formula to check every individual decimal, I don't know if that's even possible.

    Anything helps! thank you!

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Show decimals until different than zero

    Please Login or Register  to view this content.
    Kind regards
    Leo
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    04-15-2013
    Location
    Singapore, Melbourne
    MS-Off Ver
    Office 365
    Posts
    167

    Re: Show decimals until different than zero

    Example:
    Your [A1] is 0.0008456, please enter below formula in [B1]
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Row row row your boat
    Gently down the stream

  4. #4
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,577

    Re: Show decimals until different than zero

    Select the range
    Format cells --> Custom --> Enter 0.##########
    Number of #'s depending the maximum digits to be displayed. In this example I have given 10 #'s. It will display maximum of 10 digits.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,813

    Re: Show decimals until different than zero

    As a scientist, naturally my favorite "2 significant figure" number format is scientific format "0.0E+0". But I also recognize that most people don't like scientific format so that probably doesn't help. I like that number formatting does not remove information from the underlying value so that it can still be used in downstream calculations.

    The simplest formula approach for "round a number to 2 significant figures" that I've found is to convert the number to text in scientific format, then back to a number =VALUE(TEXT(number,"0.0E+0")) [format as general]. Recognize that this approach completely removes all of the other information, so I only use this as the final step in a sequence of calculations. If this number needs to be used in downstream calculations, keep a copy somewhere else to its full precision for those calculations.

    In many ways, I have not found a simple way to display numbers to 2 sig figs, but those or the other solutions come close.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Registered User
    Join Date
    05-21-2021
    Location
    US,UT
    MS-Off Ver
    365
    Posts
    5

    Re: Show decimals until different than zero

    Thank you! But this doesn't stop numbers from showing after I get 2 significant values.
    I tried this one before!

    Thank you anyway!

  7. #7
    Registered User
    Join Date
    05-21-2021
    Location
    US,UT
    MS-Off Ver
    365
    Posts
    5

    Re: Show decimals until different than zero

    This one worked like a charm! Wish I understood the logic behind this formula.

    Great job!

  8. #8
    Registered User
    Join Date
    05-21-2021
    Location
    US,UT
    MS-Off Ver
    365
    Posts
    5

    Re: Show decimals until different than zero

    I understand your logic, unfortunately I'm trying to implement this in a form so people don't have to do calculations by themselves, so using exponentials doesn't really make my life easier because they wouldn't know how to read it. :')

  9. #9
    Registered User
    Join Date
    05-21-2021
    Location
    US,UT
    MS-Off Ver
    365
    Posts
    5

    Re: Show decimals until different than zero

    I didn't know how to input this, I'm guessing this is VBA, not quite there yet!
    Thanks for the help either way, beautiful coding!

  10. #10
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Show decimals until different than zero

    maybe show us the file

    Kind regards
    Leo

+ 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] how to get concatenate only to show 2 decimals
    By bdouglas1011 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-17-2018, 09:38 AM
  2. [SOLVED] VBA to have listbox row source show as 2 decimals
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-25-2016, 04:36 AM
  3. How to only show decimals if there are any
    By Myerse in forum Excel General
    Replies: 4
    Last Post: 04-20-2015, 03:58 PM
  4. Replies: 2
    Last Post: 02-13-2015, 07:36 AM
  5. [SOLVED] Show as many Decimals as Needed
    By FallingDown in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-17-2014, 08:52 AM
  6. Custom format to show decimals only when needed
    By Phalanxz in forum Excel General
    Replies: 8
    Last Post: 05-21-2014, 11:40 AM
  7. [SOLVED] 0;-0;;@ - format to show as two decimals places
    By johnmitch38 in forum Excel General
    Replies: 3
    Last Post: 09-05-2012, 09:34 AM

Tags for this Thread

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