Sub topic 2
Highlighting cells by value, text and duplicates
This chapter assumes you can select ranges, apply a fill or font color, and enter data in cells. You do not need to write formulas yet.
How the built-in rules work
The Highlight Cells Rules menu holds the simplest rules. Open it from Home > Conditional Formatting > Highlight Cells Rules. You select a range first, then choose a rule. Excel tests each cell in the selection on its own. If the test is true, Excel applies the format you picked. If it is false, the cell keeps its normal look.
The menu offers these rules:
| Rule | What it tests |
|---|---|
| Greater Than, Less Than | Number is above or below a value |
| Between | Number is within a range, ends included |
| Equal To | Cell matches a number or text exactly |
| Text that Contains | Cell includes the text anywhere inside it |
| A Date Occurring | Date falls in a period such as Yesterday or Next Week |
| Duplicate Values | Value appears more than once, or only once |
Highlighting by value
Select the cells, for example C2:C50, and choose Greater Than. Type 1000 and pick a format such as Light Red Fill with Dark Red Text. Every cell above 1000 is now shaded.
The value box can also point to a cell. Click a cell such as G1 that holds your threshold. Excel enters =$G$1. Later you can change the number in G1 and the highlighting updates. This is better than typing a fixed number into the rule.
Highlighting by text
Equal To matches the whole cell. Text that Contains matches part of it. If you enter late, both "late" and "Delivered late" are highlighted. Neither rule is case-sensitive, so "LATE" also matches.
These rules work on the value Excel stores. A number stored as text, such as "500" with a leading apostrophe, will not match a numeric test like Greater Than. Check for a small green triangle in the corner of the cell, or left-aligned numbers.
Highlighting duplicates and unique values
Choose Duplicate Values. The dialog's first dropdown lets you switch between Duplicate and Unique. Select a column of order numbers and apply the rule. Any number that appears twice or more is highlighted in every place it occurs.
The rule compares cells across the entire selection. If you select two columns, a value in column A that also appears in column B is flagged. Select only the column you want to check.
Common mistakes
- Selecting one cell. The rule applies only to that cell. Select the full range before you create the rule.
- Typing a value with symbols. Enter
1000, not$1,000. Excel compares the number, not its display. - Expecting a whole row to change. These rules format only the cells you selected. To shade an entire row, you need a formula-based rule, which a later chapter covers.
- Stacking rules unintentionally. If you apply Greater Than twice, you have two rules. Both stay active until you remove one.
Exercise
A column of invoice numbers in A2:A200 contains some that appear twice. You apply Duplicate Values, but you know "INV-104" and "INV-104 " (trailing space) are both there and neither is highlighted. Why, and how do you fix it?
Show answer
Duplicate Values compares the stored text exactly, so the trailing space makes the two entries different. Add a helper column with =TRIM(A2), fill it down, and apply the Duplicate Values rule to the helper column. You can also clean column A itself with Find and Replace or TRIM and Paste Special as values.
Exercise
You want to highlight every cell in B2:B100 that contains the word "refund" anywhere in the text, regardless of capitals. Which rule do you use and what do you enter?
Show answer
Select B2:B100, choose Home > Conditional Formatting > Highlight Cells Rules > Text that Contains, and enter refund. The rule is not case-sensitive, so "Refund" and "REFUND" also match.