Sub topic 5
Relative and absolute references in rule formulas
Assume you can select a range in Google Sheets, enter values, and write simple formulas. This chapter focuses on custom formula rules in conditional formatting. You will use cell references to control which value each rule checks.
Why references matter
A conditional formatting rule can use a formula to decide whether to format a cell. Google Sheets evaluates that formula for each cell in the rule's apply range.
For example, suppose this table is in A2:F100:
| A | B | C | D | E | F |
|---|---|---|---|---|---|
| 101 | Write report | Done | 2026-11-20 | Lee | High |
To highlight every row whose status in column C is Done, use this custom formula:
=$C2="Done"The dollar sign before C keeps the check in column C. The row number 2 has no dollar sign, so it changes as Google Sheets evaluates each row.
For row 2, the formula checks C2. For row 3, it checks C3. For row 4, it checks C4. Because the rule applies to columns A through F, the same status cell controls the formatting of the whole row.
Relative and absolute references
A relative reference changes when Google Sheets moves the formula to another cell. An absolute reference stays fixed. A dollar sign makes either the column, the row, or both absolute.
| Reference | Column behavior | Row behavior | Example use |
|---|---|---|---|
| `C2` | Changes | Changes | Check a value relative to each cell |
| `$C2` | Fixed | Changes | Check column C for every row |
| `C$2` | Changes | Fixed | Check row 2 across columns |
| `$C$2` | Fixed | Fixed | Always check one specific cell |
The reference $C2 is useful for row-based rules. When applied to A2:F100, it means “use column C from the current row.” If you use C$2 instead, every row may check row 2, which usually produces the wrong result.
How the same formula moves
The formula is written once, but Google Sheets adjusts its relative parts as it evaluates different cells.
Selecting the correct starting cell
The row number in a custom formula should usually match the first row of the apply range.
If the range is A2:F100, start with row 2:
=$C2="Done"If the range is A5:F100, start with row 5:
=$C5="Done"Using $C2 with a range that starts at row 5 makes the first formatted row check C2 instead of C5. The rule may appear shifted by three rows.
To create the rule:
- Select the range, such as
A2:F100. - Select Format, Conditional formatting.
- In the rule panel, choose Custom formula is.
- Enter the formula.
- Choose a formatting style and select Done.
Anchoring a fixed comparison
Sometimes every cell should be compared with one fixed cell. For example, to highlight values in A2:A100 that are greater than a limit stored in F1, use:
=$A2>$F$1$A2 checks column A in the current row. $F$1 always points to the limit cell. Without the dollar signs around F1, the comparison cell could move as the rule is evaluated.
A reference can also fix only the row. For example, a rule applied to B2:E20 might compare each column with a header in row 1:
=B2>B$1Here, the column changes as the rule moves across the range, but row 1 stays fixed.
Common reference errors
- The apply range starts at row 2, but the formula starts with row 1. The formatting appears one row too high or too low.
- The formula uses
C2instead of$C2. Formatting shifts across columns because each cell checks its own column. - The formula uses
$C$2. Every row checks the same status cell, so the entire range may receive one result. - The formula checks a text value with different spelling or capitalization, such as
Donewith an extra space. The comparison then returnsFALSE. - The rule applies to a larger range than expected. Empty cells can also be evaluated, so include only the rows that should be formatted.
A practical pattern
For a task list with status in column C, due date in column D, and status in column E, this rule highlights overdue unfinished rows:
=AND($D2<TODAY(),$E2<>"Done")Applied to A2:E100, the formula fixes the columns but lets the row change. Each row checks its own due date and status.
When a rule behaves incorrectly, write down the top-left cell of the apply range. Then substitute that row into the formula manually. For A2:E100, test AND($D2<TODAY(),$E2<>"Done"). If that result is correct, test the next row with row 3. This often reveals an incorrect anchor.
Exercise
You want to format A2:F50 whenever the value in column E for that row is High. Which custom formula should you use, and why?
Show answer
Use =$E2="High". The dollar sign fixes the checked column at E, while the row number remains relative so row 2 checks E2, row 3 checks E3, and so on.