0

I am trying to have decimal places display based on the value inside a given cell. I more or less understand how to custom rules work, and have come up with this rule: [>=10]#,##0.0;[<10]0.00

It does work as expected, but the problem is that I need a third condition, and can't figure out how to do it, or if it is even possible. I need these conditions:

if the value is >= 100: no decimal places

if the value is >= 10 && < 100: one decimal place

and if the value is < 10: two decimal places

I have read multiple articles on this type of formatting, but they all only show two conditions. Is it possible to have three conditions or am I limited to two? Thanks in advance!

Articles I read include this one, this one, and this one

3
  • 1
    Set your standard with no decimals, then create a Conditional Format for all numbers less than 100 using the number format you have. Commented Dec 23, 2019 at 19:16
  • @ScottCraner I like this idea, and maybe I am missing something, but if I set my number decimal format to zero decimal places, then apply my rule, my rule overrides the number decimal format.
    – Randi
    Commented Dec 23, 2019 at 19:27
  • You apply the rule through conditional formatting, so only the numbers that are less than 100 get the format and rest get the base format. Commented Dec 23, 2019 at 19:28

3 Answers 3

1
  1. Set all the cells as the format you want without the decimal.

  2. Create a Conditional Formatting rule of =A1<100 applied to the whole column.

  3. Use the custom number format of [>=10]#,##0.0;[<10]0.00

enter image description here

1
  • 1
    Ah okay I see what I was missing! This worked perfectly. A bit tedious but that's excel. Thanks!
    – Randi
    Commented Dec 23, 2019 at 19:35
0

If you're not married to the idea of using a formula to determine your formatting, you can also use two conditional formatting rules in series, as shown below:

Formatting rules

As has been suggested in the previous answers, set your base formatting to exclude decimals. Then create the two formatting rules (rule for <10 shown below):

  1. Click Conditional Formatting
  2. Select New Rule...
  3. Format only cells that contain
  4. Set the cell value to less than 10 (and 100 in the second rule)
  5. Set your formatting to the desired number of decimals

Less than 10 rule

Note that you might have to reorder the rules so that "Cell Value < 10" is assessed first. You don't have to check "Stop If True" for the first rule, but I would, just to be thorough.

0

A few things to consider in general that bear upon this problem for you, and other like it in the future:

1) As already stated, you have a "starting out" formatting that can be the beginning to your work. It is able to take two conditionals itself so before you even enter the Conditional Formatting function's world, you have two in the bag.

2) You always have the "tail end" of what you are doing to add on without any real work. What I mean is, you took care of all numbers >=100 in the first format, leaving only values below 100. You then handled all of the values left that >=10 with the second format. Now only numbers <10 remain unformatted. If you check the box for stopping if condition is met, which logically you would anyway, you just then set up one more CF rule with a formula like =A1=A1 so everything that got this far will be subject to the rule, and set that format in a straightforward way without trickiness in the formatting string.

3) Notice the clean look of M. Curler's example picture. See how beautifully easy it is to understand the formatting set-up? One rule for <10, then another for the next single format, and so on. Instead of complex formatting strings to lower the number of individual rules you have one rule for each, but they display cleanly for future maintenance or turnover to someone else, and require no special tricks. Don't even need a formula, just "cell value". That's even cleaner than `=A1=A1".

4) As part of 3), we often try to get a bit arcane in formatting strings used in normal formatting. Gosh, we can specify one of 56 or so pretty particular colors in addition to a number format! Oh my! Do it all like in 3) though and you get an essentially infinite number of colors available under the font tab, not to mention shading and patterns. The possibilities really open out and no limited, slightly arcane regular OR CF formatting.

What using CF like in 3) won't help a lot with, though it will not limit you in any way, is applying language and such formatting. Telling a cell to be formatted for Canadian date practice, say. But even here, an idea comes to mind. CF rule formulas can look at a cell in the spreadsheet itself and get the value. So if you had somewhere to select a nationality, the CF rule could read the value arising from that choice, then select the rule that applied the particular nationality particulars for formatting dates, times, commas vs. periods, and so on. So everything could shift instantly to a view that would lead to NO misunderstandings across international use.

Lots of ways to use CF arise when one gets past the idea that every single thing entered has to be "tight," has to max out the use of each little bit of a function. Which would be of great use going forward for maintaining a spreadsheet after initial build, and, dare I say it, improving it as time passes. This is not to be sneezed at, eh?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .