Sub topic 9
Getting References Right: Relative, Absolute and Mixed
This chapter assumes you can write simple formulas such as =A1+B1, select ranges, and have already met formula-based rules. Here you will learn how Excel reads cell references inside a rule, so a rule tests the cells you intend.
How a rule reads its formula
A formula-based rule is written once, from the point of view of the active cell. This is the top-left cell of the range in the Applies to box. Excel then evaluates the formula for every other cell in the range, shifting relative references as it goes.
If the range is $A$2:$E$50 and the active cell is A2, you write the formula as if it were sitting in A2.
The active cell matters. If you select A2:E50 by dragging from the bottom, the active cell may be E50, and the references you type will be offset from the intended position. Check which cell the Name Box shows before you write the formula.
The three reference types
| Type | Example | Behavior when evaluated in other cells |
|---|---|---|
| Relative | `C2` | Column and row both shift |
| Absolute | `$C$2` | Neither shifts |
| Mixed | `$C2` or `C$2` | Only the part without `$` shifts |
You can press F4 while editing a reference to cycle through these forms. In the rule dialog, F4 may only work in Edit mode. Press F2 first if the arrow keys insert references instead of moving the cursor.
Highlighting an entire row
To shade a whole row when column C exceeds 1000, apply the rule to $A$2:$E$50 with this formula:
=$C2>1000The $ locks the column, so every cell in a row checks column C. The row number has no $, so each row checks its own column C value. Row 7 tests $C7, row 8 tests $C8, and so on.
If you wrote =C2>1000 instead, column B would test C2's neighbor to its right, which is not what you want. Cell B2 would test C2, but cell C2 would test D2. Only some cells would highlight.
If you wrote =$C$2>1000, every cell would test the same single cell. The whole range would light up or none of it would.
Counting with a fixed range
Duplicate detection needs both behaviors at once. The counting range stays fixed, and the value being tested moves with the row:
=COUNTIF($A$2:$A$100,$A2)>1Applied to $A$2:$A$100, this highlights every value that appears more than once. $A$2:$A$100 is absolute so the search range never moves. $A2 is mixed so each row looks up its own value.
Combining conditions
Mixed references work the same way inside AND and OR. This rule flags rows that are overdue and not finished:
=AND($D2<TODAY(), $E2<>"Done")Each reference locks its column and lets the row move.
Row-only references
Sometimes you want the reverse. To compare each cell with a header or a threshold stored in row 1, lock the row and let the column move:
=B2>B$1Applied to B2:F50, each column compares its values with its own header value in row 1. The cell in column C compares with C$1.
A quick way to check your references
- Open Home, Conditional Formatting, Manage Rules.
- Select the rule and note the Applies to range.
- Click Edit Rule and read the formula as though it sits in the top-left cell.
- Imagine copying that formula one column right and one row down. Do the references still point where you want?
Exercise
A table sits in A2:E50. You want the whole row shaded when column E equals "Late". You apply =E2="Late" to A2:E50 and only column E cells shade. What formula fixes this, and why?
Show answer
Use =$E2="Late". Without the $, the column reference shifts, so cell A2 tests A2 and B2 tests F2 and so on. Locking column E makes every cell in the row test column E, while the relative row number lets each row test its own value.
Exercise
You want to highlight any value in B2:F50 that is greater than the target in row 1 of its own column. Write the formula, assuming B2 is the active cell.
Show answer
=B2>B$1. The row is locked so every cell compares with row 1, and the column stays relative so each column uses its own target.