Reputation: 615
I know how I can change the colour of a cell with the help of conditional formatting. But I would like to use a formula to achieve the following goal.
If a value <5.00%
is entered into A2
via a formula, I want it to be displayed in Red 3
. If it is >=5.00%
, I would like it to be displayed in Green 3
. Analogously, the same is true for A3
/A4
/A5
compared with B3
/B4
/B5
.
STYLE
is used for background colours.
I have also stumbled upon this solution, but it is suited for text replacement and not for my purpose. After creating two new custom styles, I have tried =T(STYLE(IF(A2<B2;"Red_if_lesser";"Green_if_greater_or_equal")))
, but it has delivered an error (Err:522
). What do I have to add to this formula in order to make it work?
Upvotes: 2
Views: 2922
Reputation: 13618
For conditional formatting, it doesn’t matter if the cell value is calculated or it’s a fixed value. All you need to do is to define the appropriate rules for conditional formatting. In your case, you'll have to define two rules, one for current values < plan values
, and one forcurrent values >= plan values
. To change the font colour, define two new cell styles (can be done inside the conditional formatting dialogue), with an appropriate font colour:
Let’s start with the following data:
Select the cells that should be formatted based on their content. Pay attention that they are marked in this way:
Start defining the conditional formatting:
First rule: Cell value is
less than
B2
– apply a new style:
Set the Font Color for the new style in the Font Effects tab:
Add another formatting rule using the Add button – now with green font color:
Et voilà – the result:
Upvotes: 3