Sub topic 4
Mixed references: locking only the row or the column
This chapter assumes you can enter and edit a basic formula, select ranges, and fill formulas with the fill handle. It also assumes you know that a relative reference such as B2 shifts when copied, and that an absolute reference such as $E$1 does not. Here you will learn the third type, the mixed reference, which locks only one half of an address.
What a mixed reference is
A cell address has two parts: a column letter and a row number. A dollar sign locks the part that follows it. A mixed reference locks one part and leaves the other free to shift.
| Notation | Column | Row | Behavior when copied |
|---|---|---|---|
| `B2` | relative | relative | Both shift |
| `$B$2` | locked | locked | Neither shifts |
| `$B2` | locked | relative | Column stays B, row shifts |
| `B$2` | relative | locked | Column shifts, row stays 2 |
Read the dollar sign as "freeze whatever comes next." In $B2, the $ sits before B, so the column is frozen. In B$2, the $ sits before 2, so the row is frozen.
Why you need it
Some calculations combine two sets of inputs. One set runs down a column and the other runs across a row. A single formula must then lock the column for one input and the row for the other.
A multiplication table is the classic case. Row headings go in A2:A10 and column headings go in B1:J1. Each result multiplies one row heading by one column heading.
Enter this formula in B2:
B2: =$A2*B$1The formula has two references, and each one is locked differently:
$A2locks the column. When you fill right, it keeps pointing at column A, the row headings. When you fill down, the row changes, so each row reads its own heading.B$1locks the row. When you fill down, it keeps pointing at row 1, the column headings. When you fill right, the column changes, so each column reads its own heading.
Fill the formula across to J2, then down to J10. One formula produces all 81 results.
How the references shift
Here is what Excel writes in a few cells after you fill the formula from B2.
| Cell | Formula | What it multiplies |
|---|---|---|
| `B2` | `=$A2*B$1` | A2 by B1 |
| `C2` | `=$A2*C$1` | A2 by C1 |
| `B3` | `=$A3*B$1` | A3 by B1 |
| `D4` | `=$A4*D$1` | A4 by D1 |
In every cell, the column in the first reference is always A and the row in the second reference is always 1. The other halves change with the cell's position.
Choosing which half to lock
To decide where the dollar signs go, ask two questions about each reference in your formula:
- When I fill across, should this reference stay in its column or move to the next one?
- When I fill down, should this reference stay in its row or move to the next one?
Lock whatever should stay put. A reference to a row heading must keep its column when you fill across, so lock the column ($A2). A reference to a column heading must keep its row when you fill down, so lock the row (B$1).
If a reference must stay put in both directions, use a full absolute reference such as $E$1. If it must move in both, leave it relative.
Another example: price by discount tier
Suppose prices are listed in A2:A6, and discount rates are in B1:D1 (10%, 15%, 20%). You want the discounted price for every combination.
B2: =$A2*(1-B$1)Fill this across to D2 and down to D6. Column A stays locked so each row uses its own price. Row 1 stays locked so each column uses its own discount rate.
Typing and checking mixed references
You can type the dollar signs by hand. You can also select a reference inside the formula bar and press F4, which cycles through the four forms. The next chapter covers that shortcut.
To check your work, fill the formula into the full grid, then click a cell in the far corner, such as J10. Its formula should read =$A10*J$1. If the first reference has moved off column A, or the second has moved off row 1, a dollar sign is misplaced.
Common errors
- Locking the wrong half. Writing
A$2*$B1in a multiplication table swaps the locks, so the row headings and column headings are read from the wrong places and the table fills with wrong values. - Using a full absolute reference. Writing
$A$2*$B$1produces the same number in every cell, because nothing moves. - Using no dollar signs. Writing
A2*B1drifts diagonally. ByD4it multipliesD4byC3, which is meaningless.
Exercise
Prices are in A2:A20 and a column of quantities is in B1:F1 (five scenarios). You want C2 and everything around it to hold price times quantity for every combination, starting in B2. Which formula do you enter in B2 so it can be filled across and down? Which formula will appear in D5?
Show answer
Enter =$A2B$1 in B2. In D5 the formula is =$A5D$1. Column A is locked so every row reads its own price, and row 1 is locked so every column reads its own quantity.
Exercise
A formula =A$2*$B1 was filled from C3 to E5 in a table where row headings are in column A and column headings are in row 2... what is wrong with the locking if the intent was to multiply a row heading from column A by a column heading from row 2, and what is the corrected formula in C3?
Show answer
The locks are on the wrong halves. A$2 locks row 2 but lets the column move, and $B1 locks column B but lets the row move, so neither follows the intended heading. The corrected formula in C3 is =$A3*C$2: column A is locked for the row headings, and row 2 is locked for the column headings.