Sub topic 15
Highlighting Cells with Conditional Formatting
Assume you can select ranges, enter formulas, and use the Google Sheets toolbar. Conditional formatting changes a cell’s appearance automatically when its value meets a rule. It changes the display, not the stored value.
How conditional formatting works
A conditional formatting rule has three parts:
- Apply to range: the cells that may receive formatting.
- Condition: the test Sheets performs, such as “greater than 100.”
- Format style: the appearance to apply, such as a fill color or bold text.
For example, suppose A2:C100 contains sales records and column C contains sales totals. To highlight rows with totals above 100:
- Select
A2:C100. - Open Format > Conditional formatting.
- Under Format cells if, choose Custom formula is.
- Enter this formula:
=$C2>100- Choose a fill color.
- Select Done.
The dollar sign fixes the column reference at C. The row number remains relative, so Sheets tests C2 for the first row, C3 for the second row, and so on.
| Rule type | Example | Typical use |
|---|---|---|
| Number is greater than | `100` | Highlight high values |
| Text contains | `Overdue` | Mark status labels |
| Date is before | Today | Find past-due dates |
| Custom formula | `=$C2>100` | Format a whole row from one column |
Custom formulas and reference behavior
A custom formula must evaluate to TRUE or FALSE. Use references carefully:
=$C2>100checks column C while allowing the row to change.=C2>100also changes the column when the rule is copied across a range.=$C$2>100checks only cell C2 for every cell in the selected range.
The formula is evaluated relative to the upper-left cell of the apply-to range. If the range starts at A2, write the formula as though you are testing row 2.
> callout note > If the formatting appears on the wrong rows, check both the starting row of the selected range and the row number in the custom formula.
Rule order and common errors
Sheets can have several rules for the same range. When rules overlap, their order can affect the visible result. Review the rules in the conditional-formatting panel and move specific rules above broad rules when necessary.
Common errors include:
- Selecting only column C when the intention is to highlight the entire row.
- Using
$C$2when each row should use its own value. - Including a header row in the range while starting the formula with row 2.
- Comparing numbers stored as text. A value that looks like
125may not satisfy a numeric condition if it was imported as text. - Creating a rule for the wrong sheet or range.
You can edit a rule from the same panel, duplicate it, change its format, or delete it. Conditional formatting is useful for review, but it does not prevent invalid entries. Use data validation when input must be restricted.
Exercise
You want to highlight A2:D50 whenever the status in column D is exactly Needs review. Which custom formula should you use?
Show answer
Use =$D2="Needs review". The fixed column keeps the test in column D, while the relative row number checks each row.