Conditional formatting based on comparative value

RodneyW

Active Member
Joined
Sep 24, 2010
Messages
481
Office Version
  1. 2013
Platform
  1. Windows
I want to compare C20 and C21. These values will change based on several variables.

I need a formula that compares these two values and allows me to change the font color and cell background for the higher of the two.

Within the Conditional Formatting I'd use the "Use Formula to determine which cells to format" and have something in C20 such as =IF >C21

but that doesn't work. Any ideas?

Using Microsoft Professional Plus 2013

Thanks in advance
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Book1
BCD
20
210
221
23
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C22Expression=C22>C21textYES
C21Expression=C21>C22textYES


Book1
BCD
20
211
221
23
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C22Expression=C22>C21textYES
C21Expression=C21>C22textYES


Book1
BCD
20
211
220
23
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C22Expression=C22>C21textYES
C21Expression=C21>C22textYES
 
Upvote 0
change the font color and cell background for the higher of the two.
What if they are equal?

In any case, my preference would be to have a single Conditional Formatting rule to cover both cells.
From what you said above I am assuming the cells contain formulas & I am also assuming those formulas return numerical values. (Please give details if the assumptions are incorrect)

In the mini sheet below I have given two options.
The CF in column C would format both cells if they are equal.
The CF in column E would format neither cell if they are equal.

25 01 19.xlsm
CDE
19
201316
21281
22
CF Max
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E20:E21Expression=E20<>LARGE(E$20:E$21,2)textNO
C20:C21Expression=C20=MAX(C$20:C$21)textNO
 
Upvote 0
Book1
BCD
20
210
221
23
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C22Expression=C22>C21textYES
C21Expression=C21>C22textYES


Book1
BCD
20
211
221
23
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C22Expression=C22>C21textYES
C21Expression=C21>C22textYES


Book1
BCD
20
211
220
23
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C22Expression=C22>C21textYES
C21Expression=C21>C22textYES
Kevin, thank you. It worked perfectly. Peter, I tried Kevin's before I saw yours. To answer your question, the two numbers will never be equal. Thanks for your input as well.
 
Upvote 0

Forum statistics

Threads
1,225,738
Messages
6,186,728
Members
453,368
Latest member
positivemind

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top