Peter White
Peter White

Reputation: 1086

Encode formatting information into a Google Sheets or Excel formula

I'm using an Excel document opened in Google Sheets. I understand that either Google Sheets syntax or Excel syntax may therefore be used, so either style would be useful to me here.

I'm have a cell which compares two durations.

For example:

Cell 1 = 01:05
Cell 2 = 01:15
Cell 3 = 00:10 [RED]

If Cell 2's duration is greater than cell 1's then cell 3 should be colored red. If not, then green.

I can't do this using conditional formatting because the cell 3 is always a positive number, so I have to following formula to compute cell 3 (which is placed in cell 3:

=IF(C2 > C1, [RED]C2 - C1, [GREEN]C1 - C2)

The above is producing the correct values with the colors removed, but but the can't find away to implement the red and green successfully. If the colors are included it gives a parsing error.

Upvotes: 1

Views: 24

Answers (1)

Tom Sharpe
Tom Sharpe

Reputation: 34230

Set the fill colour of C3 to green then in conditional formatting for C3 use custom formula:

=C2>C1

with fill colour red.

Upvotes: 2

Related Questions