Templates, guides & honest tool reviews for small business

Sunday, November 29, 2026

Conditional Formatting in Excel Based on Another Cell: Step-by-Step Formulas

Conditional formatting in Excel based on another cell
Illustration: Conditional formatting in Excel based on another cell

Conditional formatting in Excel based on another cell lets you color a whole row, or a cell, depending on what is in a different cell. You do it with a formula rule. A task list can turn red when the status column says Overdue, or a price can turn green when it is below a target in another cell. This guide shows the steps and the formulas with made-up data, how to lock the right part of the reference and how to fix a rule that colors the wrong cells.

Highlight a whole row based on one cell

Say your table is in A2:E20, and column D holds a status. To color the whole row when D says Overdue:

  1. Select the range A2:E20.
  2. On the Home tab, click Conditional Formatting, then New Rule.
  3. Choose Use a formula to determine which cells to format.
  4. Type this formula:

=$D2="Overdue"

  1. Click Format, choose a fill color and click OK twice.

The dollar sign before D locks the column, so every cell in the row checks column D. The row number has no dollar sign, so each row checks its own status. Write the formula as if you were typing it for the top-left cell of the selected range, which is A2 here.

Excel conditional formatting formula to highlight a whole row when status is Overdue
Made-up task list (illustration).

Compare with a number in another cell

To color a price green when it is below the target price stored in G1:

=B2<$G$1

Select B2:B20 first. Here both parts of G1 are locked, because every row should compare with the same target. The idea of locking with dollar signs is explained in our guide to the absolute reference in Excel.

Excel conditional formatting comparing prices with a target cell
Lock the target with dollar signs (illustration).

Highlight with two conditions

Use AND or OR inside the rule. To color rows that are Overdue and above 1,000 in column C:

=AND($D2="Overdue", $C2>1000)

The same functions are explained in the IF formula with AND and OR.

Highlight dates that have passed

To color a due date in column E that is earlier than today:

=$E2<TODAY()

To exclude rows already marked Done, combine the two tests: =AND($E2<TODAY(), $D2<>"Done").

Highlight blanks or non-blanks

To color rows where the name in column A is empty, use =$A2="". For rows that have a name, use =$A2<>"".

Highlight duplicates in another column

To color a row when its name appears more than once in column A:

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

See how to remove duplicates in Excel for more ways to deal with repeated values.

Manage and order rules

Open Conditional Formatting, then Manage Rules. You can change the range under Applies to, edit a formula, delete a rule and change the order. Rules at the top have priority. If two rules set the same property, such as the fill color, the higher one wins. Use the Stop If True box when you want lower rules to be ignored for a cell.

Excel Manage Rules: rule priority and Stop If True
Top rules have priority (illustration).

Clear the rules

Go to Conditional Formatting, then Clear Rules, and choose to clear from the selected cells or from the whole sheet.

Why the rule colors the wrong cells

  • Colors shifted by one row. The formula was written for a different cell than the top-left cell of the selected range.
  • Only one column colored. You forgot the dollar sign before the column letter.
  • Everything colored. The formula has dollar signs on the row too, so it always checks the same row.
  • Nothing colored. The text in the cell has an extra space, or the number is stored as text.
  • Another rule overrides it. Check the order in Manage Rules.
Fixes when Excel conditional formatting colors the wrong cells
Check the references (illustration).

Google Sheets version

The same idea works in Google Sheets with the Custom formula is option. Read conditional formatting in Google Sheets.

Questions and answers

Can I use a formula that refers to another sheet?

Current versions of Excel allow references to other sheets in a conditional formatting formula. Older versions may need a named range. Test it in your version.

Does the formatting change my data?

No. It changes only how the cells look.

How many rules can I add?

Excel does not set a small limit for normal use, but many rules make the file slow. Keep the rules simple and apply them to exact ranges.

Can I copy the formatting to another table?

Yes. Use Format Painter, or Paste Special and choose Formats.

Summary

Select the range, make a formula rule written for the top-left cell, lock the column with a dollar sign for row highlights and check the rule order if the result looks wrong.

العربية