+ Reply to Thread
Results 1 to 6 of 6

Conditionally assigning number of decimal places displayed

  1. #1
    Registered User
    Join Date
    11-10-2003
    Location
    london
    Posts
    14

    Conditionally assigning number of decimal places displayed

    Hi All,

    Is there any way to conditionally control the number of decimal places displayed by a cell based on its value? More specifically, i want zero decimal places if the value is greater than 100; 2 decimal places for values less than 100.

    Decimal places doesn't appear to be configurable using the standard conditional formatting, and I’ve had no joy experimenting with the "if" function.

    Any comments/help appreciated.

    Thanks
    The Grinch

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Hi, Grinch.

    Is VBA a viable solution for you?

    Jason

  3. #3
    Registered User
    Join Date
    11-10-2003
    Location
    london
    Posts
    14
    Yes, i'd be happy to run a macro to affect the changes. Unfortunately i dont know how to write/record one that would provide the behaviour described above...

    Thanks
    The Grinch

  4. #4
    Forum Contributor
    Join Date
    02-23-2005
    Location
    England
    Posts
    110
    First of all make sure that the cells you wish to conditionally format are formatted as "General"; NOT as "Number" with two decimal places.

    Next use the following modification to your equation:

    IF(YourEquation > 100, Round(YourEquation,0), Round(YourEquation,2))

    The above modification will perform normal rounding so 1000.6 will come out as 1001.

    If you want to just remove the fractional part of the number, then use :

    IF(YourEquation > 100, RoundDown(YourEquation,0), RoundDown(YourEquation,2))

  5. #5
    Registered User
    Join Date
    11-10-2003
    Location
    london
    Posts
    14
    Thanks Peter, The problem is i want to also format the cell as "currency", this forces you to choose a decimal place setting which will over-write the effect of your "if" nested "round" functions.

    Actually, I supposed i could leave it as a general formatting and just concatenate in a pound sign...

    CHEERS
    The Grinch

  6. #6
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Use the following event macro ...
    Please Login or Register  to view this content.
    HTH
    Carim


    Top Excel Links

+ 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