SOLVED

Conditional number color format

Copper Contributor

#Office365 #Office2016 (If conditional formats)

 

Hi All. Is there a way that I can make a returned sum of numbers a specific color? I would like negative numbers to be red, positive numbers green and 0 black.

I have tried searching in here and I only get formatting cell color results :( 

I am on a formula looking a bit like this:

 

=if(E34-(E17+E29)>"0",[apply hex code for green]),(E34-(E17+E29)<"0",[apply hex code for red]),(E34-(E17+E29)="0",[apply hex code for black]))

 

where

[apply hex code for "color"]

gives the NUMBER the color NOT the cell.

 

I might be down the wrong track so please, if anyone can help please do :)

 

Regards

Peter

8 Replies

@PeterVelschow Look into applying custom number formats to achieve this. An example is given in the picture below.

Screenshot 2020-10-31 at 06.21.41.png

More about customising number formats here:

https://support.microsoft.com/en-us/office/review-guidelines-for-customizing-a-number-format-c0a1d1f... 

best response confirmed by PeterVelschow (Copper Contributor)
Solution

Hi @PeterVelschow 

 

The simplest and most flexible approach is to use Conditional Formatting

 

Just apply 3 rules

 

image.pngimage.pngimage.png

@PeterVelschow @Riny_van_Eekelen @Wyn Hopkins 

Two good solutions but which is the better?

1. Conditional formatting has a proper user interface supporting the definition of complex formatting rules.  On the other hand, there is a maintenance burden as drag-and-drop gradually scrambles the region to which the  formatting is applied (I wonder why CF does not support defined ranges properly?).

2. Number formatting is an arcane skill conducted requiring obscure codes to be applied within a user-hostile development context.  That said, the functionality is an exact match for the OP's stated requirement.  Number formatting can also be introduced as part of an applied Style which, at least,, make its definition a one-off task (I wonder what proportion of users employ Styles routinely?).

 

The only change I would make to Riny's solution is to use [Color10] rather than [Green] if it is to be viewed against a white background.

image.png

(Tried to edit this in to the previous post but wasn't allowed)

Hi @Wyn Hopkins 

Thanks a lot for the fast and clarifying response. I had searched for precisely that way to color my numbers, but simply oversaw it. Now things work as a charm :)

 

Regards

Peter

How do you color cell. Red if negative. Blue if positive

@langben 

That's in @Riny_van_Eekelen post in this thread above

Hi Sergei,
Thank you very much for the response to my question.
Best Wishes,
Ben
1 best response

Accepted Solutions
best response confirmed by PeterVelschow (Copper Contributor)
Solution

Hi @PeterVelschow 

 

The simplest and most flexible approach is to use Conditional Formatting

 

Just apply 3 rules

 

image.pngimage.pngimage.png

View solution in original post