Nemgathos
Nemgathos

Reputation: 615

How can I change the font (not cell!) colour with an IF-condition?

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.

enter image description here

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

Answers (1)

tohuwawohu
tohuwawohu

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:

  1. Let’s start with the following data:

    enter image description here

  2. Select the cells that should be formatted based on their content. Pay attention that they are marked in this way:

    enter image description here

  3. Start defining the conditional formatting:

    enter image description here

  4. First rule: Cell value is less than B2 – apply a new style:

    enter image description here

  5. Set the Font Color for the new style in the Font Effects tab:

    enter image description here

  6. Add another formatting rule using the Add button – now with green font color:

    enter image description here

  7. Et voilà – the result:

    enter image description here

Upvotes: 3

Related Questions