+ Reply to Thread
Results 1 to 8 of 8

Show as many Decimals as Needed

  1. #1
    Forum Contributor
    Join Date
    12-19-2011
    Location
    Central Europe
    MS-Off Ver
    Excel O365
    Posts
    361

    Show as many Decimals as Needed

    Hi everyone

    I am looking for a way to display a minimum of two decimals, but where needed upto 5.

    So let's say with "general" formatting my numbers look like

    1005.15
    25.252
    35694.25698
    400
    36.147

    So the result should be

    1,005.15
    25.252
    35,694.25698
    400.00
    36.147

    Is there any way I could achieve this? Alternatively I am also happy with a VBA code... but I suspect this can be solved with formatting only.

    Thanks in advance

    FD
    Last edited by FallingDown; 06-17-2014 at 08:52 AM.

  2. #2
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Show as many Decimals as Needed

    You can use the ROUND function.

    Say the given values are in col A one below the other from A2 onwards, then use,
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and copy down. This will round the decimals to 2 places.

    If these values are generated from a formula, enclose it within the ROUND function as
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If my assistance has helped, there is a reputation icon * on the left hand corner below the post - you can show your appreciation to the user who has helped in resolving your requirement.

    If your requirement has been solved please mark your thread as Solved.
    In the menu bar above the very first post, select Thread Tools, then select "Mark this thread as Solved".

    Kindly use [FORMULA] or [CODE] tags when posting your code.

    Regards,
    Sarang

  3. #3
    Forum Contributor
    Join Date
    12-19-2011
    Location
    Central Europe
    MS-Off Ver
    Excel O365
    Posts
    361

    Re: Show as many Decimals as Needed

    Hi Sarang

    This, as the function says, rounds it up/down to two decimals
    But that's not what I want

    As indicated, my numbers are

    1005.15
    25.252
    35694.25698
    400
    36.147

    So the result should be

    1,005.15
    25.252
    35,694.25698
    400.00
    36.147

    So you can see that the numbers still have upto 5 decimals (which should also remain)
    But it should add the thousand separator, and show a minimum of 2 decimals

    Regards
    FD

  4. #4
    Valued Forum Contributor
    Join Date
    10-06-2008
    Location
    Norway
    MS-Off Ver
    2010
    Posts
    365

    Re: Show as many Decimals as Needed

    Hi try:
    Select cell with 1005,15 (in my example A2)
    Home ->
    Conditional Formatting ->
    New Rule ->
    Use a formula to determine which cells to format ->

    Format values where this formula is true:
    =OR(TRUNC(A2,1)=A2,INT(A2)=A2)

    choose number format with 2 decimals
    copy format to the other cells

    This should format numbers with zero or one decimal, and leave the other numbers as they are.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Show as many Decimals as Needed

    @Saarang84


    I believe the OP is looking for a solution that will display as many decimal places as necessary with a minimum of 2 and including the thousands separator.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  6. #6
    Valued Forum Contributor
    Join Date
    10-06-2008
    Location
    Norway
    MS-Off Ver
    2010
    Posts
    365

    Re: Show as many Decimals as Needed

    PS I'm not sure how to add separator without at the same time setting number of decimals.

  7. #7
    Valued Forum Contributor
    Join Date
    10-06-2008
    Location
    Norway
    MS-Off Ver
    2010
    Posts
    365

    Re: Show as many Decimals as Needed

    PPS You could add one CF-rule for each remaining option (3 4 and 5 decimals) like this:
    =TRUNC(A2,3)=A2)
    choose number format with 3 decimals and separator

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

    Re: Show as many Decimals as Needed

    Available number format codes (http://office.microsoft.com/en-us/ma...902.aspx?CTT=1) I haven't tested it, but it seems, from the description of placeholders in number formats, that a number format code like #,##0.00### should work just fine if you don't need the decimals to line up, or #,##0.00??? if you do want the decimals to line up.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  9. #9
    Forum Contributor
    Join Date
    12-19-2011
    Location
    Central Europe
    MS-Off Ver
    Excel O365
    Posts
    361

    Re: Show as many Decimals as Needed

    @estige

    Perefect! That worked, thanks a lot!!!

    FD

+ 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. 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
  2. Custom format to show decimals only when needed
    By Phalanxz in forum Excel General
    Replies: 8
    Last Post: 05-21-2014, 11:40 AM
  3. [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
  4. Replies: 8
    Last Post: 08-15-2011, 10:12 AM
  5. No rounding needed with no decimals displayed
    By lordyoyo in forum Excel General
    Replies: 4
    Last Post: 12-19-2010, 06:58 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