Sub topic 7
Mixed references: locking only the row or the column
This chapter assumes you can write a formula that starts with =, you know A1 notation, and you know the difference between relative references (B2) and absolute references ($B$2). It covers a third kind, the mixed reference, which locks only one half of a cell address.
Why a third kind of reference exists
An absolute reference such as $F$1 never moves. A relative reference such as B2 moves in both directions. Some calculations need a reference that moves in one direction and stays put in the other.
The classic case is a grid. Values run down the left column and across the top row, and every cell in the middle combines one value from each edge. When you fill the formula down, the top-row reference must not slide down. When you fill it right, the left-column reference must not slide right.
A mixed reference does this by putting a $ in front of only one part of the address:
| Written as | Column | Row | Name |
|---|---|---|---|
| `B2` | moves | moves | relative |
| `$B$2` | locked | locked | absolute |
| `$B2` | locked | moves | mixed, column locked |
| `B$2` | moves | locked | mixed, row locked |
The $ locks whatever comes directly after it. In $B2, the $ is before the B, so the column letter is locked. In B$2, the $ is before the 2, so the row number is locked.
A multiplication table
Build a 3-by-3 multiplication table. Put the numbers 1, 2, and 3 in B1:D1 across the top. Put 1, 2, and 3 in A2:A4 down the side. Leave A1 empty.
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | 1 | 2 | 3 | |
| 2 | 1 | |||
| 3 | 2 | |||
| 4 | 3 |
In B2, type this formula:
=$A2*B$1Read it in two parts.
$A2is the side value. The column is locked on A, so the formula always reads from column A. The row is free, so it follows the formula's row.B$1is the top value. The row is locked on 1, so the formula always reads from row 1. The column is free, so it follows the formula's column.
Copy B2 and paste it over B2:D4, or drag the fill handle right and then down. Each cell adjusts only the free part of each reference:
| Cell | Formula after filling | Result |
|---|---|---|
| B2 | `=$A2*B$1` | 1 |
| C2 | `=$A2*C$1` | 2 |
| D2 | `=$A2*D$1` | 3 |
| B3 | `=$A3*B$1` | 2 |
| C3 | `=$A3*C$1` | 4 |
| D4 | `=$A4*D$1` | 9 |
You wrote one formula and it works in all nine cells. With relative references the formula would drift off the headers. With absolute references every cell would give the same result.
A diagram shows what happens to each half of the reference as the formula moves.
Choosing which half to lock
You do not need to memorize patterns. Ask one question for each reference in the formula: when I fill right, should this reference move, and when I fill down, should it move?
- Find where the value lives. A value in a header row is the same for every row of the grid, so lock the row (
B$1). - A value in a label column is the same for every column of the grid, so lock the column (
$A2). - A value that is a single cell used everywhere is locked both ways (
$F$1). - A value that is different for each cell in both directions stays relative.
Here is a second example, a price grid. Unit prices are in A2:A6 and discount rates are in B1:E1, for example 0%, 5%, 10%, and 15%. The discounted price in B2 is:
=$A2*(1-B$1)Filling this across B2:E6 gives every price at every discount. The price comes from the locked column A, and the discount comes from the locked row 1.
Now compare a tax rate stored in one cell, F1, applied to the same prices:
=$A2*(1-B$1)*(1+$F$1)The tax rate has no row or column to follow, so it uses a full absolute reference. Mixed references handle values that vary along one edge. Absolute references handle single constants.
The F4 shortcut
You can type the $ signs by hand, but there is a faster way. While you are editing a formula, put the cursor on or next to a reference and press F4. On some Mac keyboards you need Fn+F4. Each press moves the reference to the next form:
B1(relative)$B$1(absolute)B$1(row locked)$B1(column locked)- Back to
B1
If F4 does nothing on your keyboard, type the $ signs directly. The result is the same.
Mixed references in ranges
A range has two corners, and each corner is a reference. You can lock the corners separately. This is how you build a running total.
Suppose B2:B8 holds daily sales. In C2, type:
=SUM(B$2:B2)The first corner, B$2, has its row locked, so the range always starts at row 2. The second corner, B2, is relative, so the range ends at the current row. After filling down:
| Cell | Formula | What it adds |
|---|---|---|
| C2 | `=SUM(B$2:B2)` | B2 |
| C3 | `=SUM(B$2:B3)` | B2 through B3 |
| C4 | `=SUM(B$2:B4)` | B2 through B4 |
| C8 | `=SUM(B$2:B8)` | B2 through B8 |
The start stays fixed and the end grows. Locking the column as well ($B$2:B2) is also correct here, and it is safer if someone later copies the formula into another column.
What copying, cutting, and moving do
Mixed references matter when you copy a formula or fill it. They do not change what happens when you cut and paste.
- Copy and paste, and fill, rewrite the free parts of each reference to match the new position.
- Cut and paste moves the formula and leaves its references exactly as written.
- If you cut and paste a cell that other formulas refer to, those formulas follow it to its new location.
- Inserting or deleting a row or column rewrites references to match, including locked ones. A
$locks a reference against filling. It does not lock it against structural edits.
Common mistakes
Most mixed-reference bugs come from locking the wrong half, or from locking nothing. Check by filling the formula and inspecting a cell far from the origin, such as the bottom-right corner of the grid.
| Symptom | Likely cause | Fix |
|---|---|---|
| Every cell in a row or column shows the same result | A reference is locked in the direction it should move | Remove the `$` from the half that should follow the fill |
| The first row or column is right and the rest are wrong | A header reference slid away because it had no `$` | Lock the header's row (`B$1`) or column (`$A2`) |
| Results are blank or zero in the bottom rows | The reference drifted below the data into empty cells | Lock the row of the header cell |
| `#DIV/0!` in the middle of a grid | A divisor reference slid onto an empty or zero cell | Lock the divisor's row or column, then check the cell it points to |
| The grid is right until you copy it elsewhere | The formula depends on a reference that moves when the whole block is pasted | Use `$A$1` style for fixed constants |
A quick test is to click the bottom-right cell and read its formula. In the multiplication table, D4 should read =$A4*D$1. If it shows =D4*D1, the $ signs are missing. If it shows =$A$4*$D$1, you locked too much.
Filling in more than one direction
You can fill a block in one step. Select B2, copy it, select B2:D4, and paste. Sheets applies the same relative shift to every cell in the target. This is why a single mixed-reference formula can drive the whole grid: the formula in each cell is the original formula, moved by that cell's offset from B2.
If you need to enter the formula in many cells at once, select the target range, type the formula in the active cell, and press Ctrl+Enter (Cmd+Enter on Mac). The formula is entered in every selected cell and adjusts by position, just as it does when you fill.
Summary
- A mixed reference locks only the column (
$B2) or only the row (B$2). - Use it for grids where one input runs along the top and another runs down the side.
- Decide each reference separately: lock the row for values in a header row, lock the column for values in a label column, and lock both for single constants.
- In a range, each corner can have its own locks, as in the running total
=SUM(B$2:B2). - Check the bottom-right cell after filling. Its formula shows whether the locks are right.
Exercise
Column A (A2:A5) holds hourly pay rates. Row 1 (B1:D1) holds hours worked: 10, 20, and 30. Write one formula for B2 that gives pay for each rate and hours combination when filled across B2:D5. What does the formula in D5 read after filling?
Show answer
In B2 write =$A2B$1. The column of the rate is locked because the rates are always in column A. The row of the hours is locked because the hours are always in row 1. In D5 the formula reads =$A5D$1.
Exercise
A student fills =A2*B1 from B2 across B2:D4 in the multiplication table and gets wrong numbers and zeros. Which two references need a $, where does each $ go, and what does the corrected formula read?
Show answer
A2 needs its column locked, so it becomes $A2, because the side values are always in column A. B1 needs its row locked, so it becomes B$1, because the top values are always in row 1. The corrected formula is =$A2*B$1.
Exercise
In C2 you write =SUM(B$2:B2) and fill it down to C10. What does the formula in C6 read, and what does it calculate?
Show answer
C6 reads =SUM(B$2:B6). It adds B2 through B6, which is the running total of the first five values in column B.