Quick answer

Conditional formatting changes how a cell looks based on its value. Select the cells, go to Home > Conditional Formatting, and pick a rule such as Highlight Cells Rules > Greater Than, then a value and a format. For anything the built-in rules can’t do, such as coloring a whole row, choose New Rule > Use a formula to determine which cells to format and type a test like =$C2>5000.

A list of 200 invoices tells you little until the large and overdue ones stand out. Conditional formatting colors them for you, and the colors move by themselves when the numbers change.

How conditional formatting works

A rule has two parts: a condition and a format. Excel checks the condition for every cell the rule applies to, and formats the cells where it’s true. When a value changes, Excel checks again, so a cell gains or loses its color on its own.

The formatting changes only how cells look. The values stay as they were, so formulas, sorting and totals work exactly as before. One cell can have several rules; when two of them are true and set the same thing, such as the fill color, the rule higher in the list wins.

Highlight cells with a built-in rule

Say you want every invoice over $5,000 to stand out in the Amount column.

  1. Select the amounts, such as C2:C20.
  2. On the Home tab, in the Styles group, choose Conditional Formatting > Highlight Cells Rules > Greater Than.
  3. Type 5000 in the box, pick a format from the list next to it, and click OK.

The Highlight Cells Rules menu also has Less Than, Between, Equal To, Text that Contains, A Date Occurring (from Yesterday to Next month) and Duplicate Values. Top/Bottom Rules colors the largest or smallest values, such as Top 10 Items or Above Average. The free lesson Highlight cells with conditional formatting has you try these rules on real sheets.

Data bars, color scales and icon sets

These three draw the values instead of testing them, which suits a column you want to read at a glance:

  • Data Bars put a bar inside each cell, longer for larger values, so you can compare a column at a glance.
  • Color Scales shade the cells from one color to another, low to high.
  • Icon Sets add an icon, such as an arrow or a traffic light, by which band a value falls in.

Show size with data bars, color scales and icon sets shows where each color and icon comes from, and how to tie icons to a fixed target instead of the spread of the data.

Use a formula to highlight a whole row

The built-in rules color the cell they test. To color the whole invoice row when its amount is over $5,000, the rule has to test column C from every cell in the row, which takes a formula:

  1. Select the data rows without the headers, such as A2:C20, starting from A2 so that A2 is the active cell.
  2. Choose Home > Conditional Formatting > New Rule.
  3. Choose Use a formula to determine which cells to format.
  4. In the box, type =$C2>5000.
  5. Click Format, pick a fill color on the Fill tab, and click OK twice.

The formula is a test that comes out TRUE or FALSE, the same kind of test you’d put inside IF. Excel reads it as written for the active cell, A2, and adjusts it for every other cell in the range the way a copied formula adjusts. Type the same formula in a spare column and fill it down, and you see what the rule sees:

The rule colors the rows where its test is TRUE. Each row's copy of =$C2>5000 checks that row's amount. Rows 3, 5 and 7 are over $5,000, so the rule fills A3:C3, A5:C5 and A7:C7. In D3, =$C3>5000 returns TRUE.

The dollar sign is what makes the whole row light up. $C locks the column, so every cell in the row, A, B and C alike, checks the amount in column C. The row number has no $, so each row checks its own amount. Leave the $ out and the test slides across with the cells:

CellRule =$C2>5000 becomesRule =C2>5000 becomes
A2=$C2>5000=C2>5000
B2=$C2>5000=D2>5000
C2=$C2>5000=E2>5000
A3=$C3>5000=C3>5000
$C2 keeps every cell on column C; C2 doesn't. Without the $, B2 tests D2 and C2 tests E2, both empty, so only column A changes color.

If you click a cell while typing the formula, Excel puts in a fully locked reference such as $C$2. Delete the $ before the 2, or every row tests row 2. On a Mac, New Rule opens a window with a Style list: choose Classic, then Use a formula to determine which cells to format. In Excel for the web, choose New Rule and the rule type Formula. The lesson Highlight whole rows with a formula rule practices these rules on overdue checks, late deliveries and unpaid invoices.

Highlight overdue dates

With due dates in column C, this rule colors every row whose due date has passed:

=$C2<TODAY()

TODAY returns today’s date, so the rule moves on by itself each morning; the free lesson Build dates with DATE, and use TODAY and NOW explains it. To color only the unpaid ones, combine two tests with AND, which is TRUE only when both are: =AND($E2="Unpaid",$C2<TODAY()). OR works the same way when either test should do.

Highlight duplicates

Select the column and choose Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values. Excel colors every value that appears more than once, so you can look before you delete anything. How to remove duplicates in Excel shows the next step.

Manage, edit and remove rules

Home > Conditional Formatting > Manage Rules opens the Conditional Formatting Rules Manager. In Show formatting rules for, pick This Worksheet to see every rule on the sheet, then select one to edit it, change the range in Applies to, or move it with Move Up and Move Down. Rules higher in the list come first, and a new rule goes to the top. On Windows, Stop If True stops the rules below a rule from applying once that rule is true.

To remove rules, choose Conditional Formatting > Clear Rules > Clear Rules from Selected Cells, or Clear Rules from Entire Sheet.

To copy conditional formatting to other cells, select a formatted cell, click Format Painter on the Home tab and click or drag over the cells that should get it.

Manage conditional formatting rules practices widening a rule to new rows, putting two clashing rules in order and stopping one with Stop If True.

Why conditional formatting isn’t working

The $ is in the wrong place

=$C$2>5000 tests C2 from every cell, so the whole range is colored or none of it is. =C2>5000 slides across the columns, as the table above shows. For a row rule, lock the column and leave the row free: =$C2.

The formula was written for another row

Excel reads the formula as written for the first cell of Applies to. If the range starts at A2 but the formula says =$C3>5000, every row tests the row below it. Write the formula for the first cell of the range.

A number is stored as text

In an Excel comparison, text counts as greater than any number. An amount that arrived as text, such as “800” from an export, passes >5000:

The 800 stored as text passes the test. Text counts as larger than any number, so =$C3>5000 returns TRUE and the rule colors a small invoice. Convert the text to a number and it reads FALSE. In D3, =$C3>5000 returns TRUE.

Select the cell, click the warning icon beside it and choose Convert to Number, and the rule leaves it alone.

Another rule wins

When two rules are true for a cell and set the same thing, the one higher in the Rules Manager wins. Open Manage Rules, choose This Worksheet, and move the rule you want up.

The free lessons Decide with IF and Combine tests with AND, OR and NOT practice exactly these tests. The IF function page has more examples.

Frequently asked questions

How do I highlight a row based on one cell's value?

Select the rows from the first data cell, such as A2:C20, choose Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format, and type a test such as =$C2>5000. The $ keeps every cell in the row looking at column C.

How do I use IF in conditional formatting?

You don’t need IF. A rule’s formula is the test itself, such as =$C2>5000, and Excel applies the format wherever it’s TRUE. The part you’d put inside IF is the whole formula.

How do I copy conditional formatting to other cells?

Select a cell that has the formatting, click Format Painter on the Home tab, and click or drag over the cells that should get it. The rules come along with the rest of the format.

Why isn't my conditional formatting working?

Check the $ signs first: a row rule needs the column locked and the row free, as in =$C2. Then check that the formula is written for the first cell of Applies to, and that the numbers it tests aren’t stored as text.

How do I format a cell based on another cell?

Use a formula rule that points at the other cell. To color a name in A2 when its status in D2 says Late, select A2:A20 and use =$D2="Late".

How do I remove conditional formatting?

Select the cells and choose Home > Conditional Formatting > Clear Rules > Clear Rules from Selected Cells, or choose Clear Rules from Entire Sheet to remove every rule on the sheet.