Conditional formatting with a formula
The built-in rules colour single cells. A formula rule can colour a whole row, compare with other columns or use dates. The formula must return TRUE for the cells you want to format.
How do you highlight a whole row?
Select A2:F50, Home, Conditional Formatting, New Rule, "Use a formula", and enter:
=$E2="Overdue"
The $ before E keeps every cell looking at column E. The row number has no $, so each row checks its own status.
Which formulas are useful?
| Goal | Formula |
|---|---|
| Dates in the past | =$D2<TODAY() |
| Due in the next 7 days | =AND($D2>=TODAY(),$D2<=TODAY()+7) |
| Above the average | =$C2>AVERAGE($C$2:$C$50) |
| Duplicate emails | =COUNTIF($B$2:$B$50,$B2)>1 |
| Every other row | =MOD(ROW(),2)=0 |
Why does my rule colour the wrong rows?
The formula is written for the first row of the selection. If you selected from row 2, the formula must use row 2. A wrong $ is the other usual cause.
Try it yourself. Practise this in a real spreadsheet in your browser, with instant feedback.
Practise conditional formatting
Practise conditional formatting
Updated November 2026.