Cellgrids Cellgridsby LearnWithRinkesh
Home › Excel tutorials › Conditional Formatting with a Formula in Excel

How to Use a Formula in Conditional Formatting to Highlight Entire Rows

By Rinkesh Shah · Business Analyst, 8 years in data · Updated 2026-10-31

▶ Video coming soon

The ready-made conditional formatting rules only look at the cell itself. A formula rule lets you colour a whole row, or compare a cell with another column. It is the skill that makes reports look professional.

Where to find it

Select your data, then Home, Conditional Formatting, New Rule, and choose Use a formula to determine which cells to format.

Highlight the entire row if status is Done

Select A2:F200. Use this formula (it is written for the first row of the selection):

=$D2="Done"

The dollar sign before D locks the column, and the missing dollar sign before 2 lets the row change. This one detail is what makes the full row colour.

Highlight overdue dates

Due date in C, status in D:

=AND($C2<TODAY(), $D2<>"Done")

Only open items with a past due date turn red.

Highlight duplicates in a column

=COUNTIF($A$2:$A$200, $A2)>1

This also works across many rows, and you can change the colour.

Alternate row shading

=MOD(ROW(),2)=0 shades every second row.

Fix a rule that colours the wrong cells

Worked example

Highlight whole rows where status in column D is "Overdue": select A2:D100, choose Conditional Formatting → New Rule → Use a formula, and enter =$D2="Overdue". Choose a fill colour and click OK.

Common mistakes

Frequently asked questions

Why does my rule only work for one row?

The row is locked. Write $D2, not $D$2.

How do I highlight weekends?

=WEEKDAY($A2,2)>5.

How do I highlight expired dates?

=$B2<TODAY().

Practice this online, free

Reading is only half of learning Excel. Cellgrids is a free place for online Excel practice: solve Excel formula exercises in a live spreadsheet, prepare for Excel interview questions, and work through business case studies built for data analytics and business analytics roles.

Practice these formulas: COUNTIF, TODAY, AND.

Start Excel practice → Case studies