How-to guides

How to highlight cells with conditional formatting

Color cells automatically when they meet a condition, using Home, Conditional Formatting, either a ready-made rule or a formula rule for whole rows.

Conditional formatting colors a cell because of what it contains, so the color follows the data. Change a number and the highlight appears or disappears without any further clicking.

Most tasks use one of two shapes: a ready-made rule on a single column, or a formula rule when the color depends on another column in the same row.

Steps in Excel for Windows

Shortcut: Alt, H, L

  1. Select the cells to format. Drag across the column of numbers, for example B2:B5. Leave the header out so it is not tested as data.
  2. Open Conditional Formatting. On the Home tab, in the Styles group, click Conditional Formatting. The keyboard route is Alt, H, L.
  3. Choose a ready-made rule. Point to Highlight Cells Rules, then pick Greater Than. Other choices include Less Than, Between, Equal To, Text that Contains and Duplicate Values.
  4. Enter the value and the look. Type 500 in the box, pick a preset such as Light Red Fill with Dark Red Text, and click OK. The format appears at once and updates whenever a value changes.
  5. For a whole row, use a formula rule. Select the whole table body, choose Conditional Formatting, New Rule, then Use a formula to determine which cells to format. Enter =$B2>500, click Format to choose a fill, and click OK.
  6. Review or remove rules. Conditional Formatting, Manage Rules lists every rule for the selection or the sheet. Clear Rules removes them from the selected cells or the whole sheet.

Menu names are from Microsoft 365 on Windows. Excel for Mac and Excel for the web put the same commands in slightly different places.

Worked example

1. Highlight sales over 500

Before the rule
AB
1RepSales
2Ana420
3Kim610
4Raj380
5Lee705
After Greater Than 500
AB
1RepSales
2Ana420
3Kim610
4Raj380
5Lee705

The rule applies to B2:B5 and tests each value against 500. B3 holds 610 and B5 holds 705, so those two cells are highlighted. The values themselves are unchanged.

2. How a whole-row rule reads its formula

How a whole-row rule reads its formula. The formula =$C3>500 in cell D3 returns TRUE.
ABCD
1RepRegionSales
2AnaEast420
3KimWest610TRUE

A formula rule is written for the top-left cell of the selection and Excel adjusts it for every other cell. The dollar sign locks the column, so each cell in a row looks at column C, while the row number moves. For row 3 the rule becomes this test, which is TRUE for Kim's 610, so row 3 is formatted.

3. Count the cells a rule will highlight

Count the cells a rule will highlight. The formula =COUNTIF(B2:B5,">500") in cell D2 returns 2.
ABCD
1RepSales
2Ana4202
3Kim610
4Raj380
5Lee705

COUNTIF uses the same condition, so it tells you how many cells should be colored. Two of the four sales in B2:B5 are over 500.

Common mistakes

  • Forgetting the dollar sign in a row rule. Without $ in front of the column letter, a formula such as =B2>500 shifts to C2, D2 and so on as it moves across, and the highlighting stops lining up with the data.
  • Writing the formula for the wrong cell. A formula rule is relative to the active cell when you open the dialog. If the selection starts at A2 but you wrote the formula as if you were in A1, every row is off by one.
  • Numbers stored as text. A number saved as text is not compared as a number, so a Greater Than rule can miss cells that qualify or catch ones that do not. Left-aligned figures in a numeric column are the sign. Convert them first.
  • Stacking rules that fight. Rules are applied in the order listed in Manage Rules. A higher rule can override the fill from a lower one, so review the order when two rules touch the same cells.
  • Coloring cells by hand. A fill applied from the Home tab is permanent and will not change when the data does. A rule updates automatically, which is almost always what a task wants.

On Excel job tests

Prompts read "highlight all sales above 500", "shade the rows where the status is Late" or "mark duplicate IDs". Cells that depend on one value are a ready-made rule; anything that depends on another column in the same row needs a formula rule with a locked column.

Apply it as a conditional format rather than coloring cells yourself, and keep the numbers in the cells unchanged.

Questions

How do I highlight an entire row based on one cell?
Select the whole table, add a New Rule using a formula, and lock the column with a dollar sign, for example =$C2="Late". Do not lock the row number.
How do I remove conditional formatting?
Select the cells, then choose Conditional Formatting, Clear Rules, Clear Rules from Selected Cells. Clear Rules from Entire Sheet removes every rule.
Does conditional formatting change the values?
No. Only the appearance changes. Sorting and filtering by color are available from the filter menu.
What is the keyboard shortcut for conditional formatting?
On Windows, press Alt, H, L to open the Conditional Formatting menu from the Home tab.

Practice this

No free lesson covers conditional formatting yet. The closest practice is the free 5-item sampler, which uses the same kind of tasks in a working grid.

Try a 5-item Excel test sample