1 / 6 · Basic
Absolute and mixed references
One dollar sign decides whether a copied formula keeps looking at the tax rate in B1 or slides down to an empty cell.
Jump to the 10 practice questionsYou will learn
- Pin a reference with $
- Build a table from one formula with mixed references
1Explain
Why the tax column goes wrong after one fill
Start with a puzzle. The tax rate, 10%, sits in B1, and four prices sit in A4 to A7. Someone types =A4*B1 in B4, gets 2, which is right, and fills it down to B7. Now B5 shows 0, B6 shows #VALUE! and B7 shows 25. Before reading on, try to say why each of those three cells went wrong.
2Problem
What goes wrong
B1 holds 10% and B4 holds =A4*B1. You fill B4 down to B7. What goes wrong?
Hint
Read the formula in B5.
Solution
Answer: The rate reference slides off B1, so B5 shows 0 and the rows below go wrong too
B5 gets =A5*B2 and B2 is empty, so 0 with no error to warn you. B6 multiplies by the heading in B3 (#VALUE!) and B7 by the result in B4 (25).
3Explain
The rate slid to B2
Click B5 and read its formula: =A5*B2. Filling down moved every ordinary reference one row. The price reference went from A4 to A5, as it should, but the rate reference went from B1 to B2 as well, and B2 is empty. An empty cell counts as 0 in multiplication, so B5 quietly shows 0. B6 now multiplies by B3, which holds the heading Tax; Microsoft's #VALUE! page notes that operators like + and * may not be able to calculate cells that contain text, hence the error.
4Explore
Pinning with $
The fix is to tell the spreadsheet that B1 must never move. A dollar sign in front of part of an address pins that part. $B$1 pins both the column and the row, which makes it an absolute reference: it means B1 wherever the formula ends up. Write the first tax as =A4*$B$1, fill down, and you get =A5*$B$1, =A6*$B$1 and so on. Microsoft's own example is =$B$4*$C$4, which stays exactly the same when copied from D4 to D5. The sign has nothing to do with money. It is a marker.
Drag to turn. Scroll or pinch to zoom.
5Problem
One row down
Hint
$B$1 never moves.
Solution
Answer: =A5*$B$1
A4 is relative and moves; $B$1 is absolute and stays.
6Problem
F4 once
Hint
Both parts pinned.
Solution
Answer: $A$1
The cycle is A1, $A$1, A$1, $A1.
7Problem
F4 twice
Hint
Only the row stays pinned.
Solution
Answer: A$1
The second step fixes only the row.
8Problem
F4 on a Mac
Which key switches reference types on a Mac in Google Sheets?
Hint
The function keys need Fn.
Solution
Answer: Fn+F4
Google's Mac list: Absolute/relative references, Fn + F4.
9Explain
One rate cell for every row
Keeping the rate in its own cell pays off a second time. If the rate changes from 10% to 12%, you edit B1 and every row recalculates at once. Had the rate been typed into each formula as *0.1, you would have to hunt down every copy, and the one you miss leaves a wrong figure that looks perfectly normal. So put anything that might change (rates, limits, exchange rates) in labelled cells near the top. Point at them with absolute references.
10Explain
Pinning only the row, or only the column
You can pin just one part. In A$1 the row is pinned and the column moves; in $A1 it is the other way round. Microsoft's table copies each form two cells down and two cells right: $A$1 stays $A$1, A$1 becomes C$1, $A1 becomes $A3, and A1 becomes C3. You will seldom type the signs by hand. While editing a formula, put the cursor on a reference and press F4. Each press steps to the next form (A1, $A$1, A$1, $A1) and then back to A1. Google's shortcut list gives F4 for Sheets as well, and Fn+F4 on a Mac keyboard.
| Reference | Column | Row | Copied 2 down, 2 right |
|---|---|---|---|
| A1 | moves | moves | C3 |
| $A$1 | fixed | fixed | $A$1 |
| A$1 | moves | fixed | C$1 |
| $A1 | fixed | moves | $A3 |
11Explore
Four kinds of reference
Each reference copied two cells down and two cells right. A $ keeps the part that follows it.
const colNum = (s) => [...s].reduce((n, ch) => n * 26 + ch.charCodeAt(0) - 64, 0);
const colName = (n) => (n > 26 ? colName(Math.floor((n - 1) / 26)) : "") + String.fromCharCode(65 + ((n - 1) % 26));
const ref = "A$1", down = 2, right = 2;
const [, c$, col, r$, row] = ref.match(/(\$?)([A-Z]+)(\$?)(\d+)/);
const c = c$ ? col : colName(colNum(col) + right);
const r = r$ ? row : Number(row) + down;
console.log(c$ + c + r$ + r);C$112Problem
A$1 copied
Hint
The column moves, the row stays.
Solution
Answer: =C$1
The column moves two letters; the row stays at 1.
13Problem
$A1 copied
Hint
The row moves, the column stays.
Solution
Answer: =$A3
The column stays at A; the row moves from 1 to 3.
14Problem
Row fixed, column free
Which reference keeps the row fixed but lets the column move?
Hint
The $ goes in front of the row number.
Solution
Answer: A$1
The $ sits in front of the part it fixes: here the row number.
15Explore
A multiplication table from one formula
Where do mixed references earn their keep? In a grid with one input along the top and another down the side, and a multiplication table is the classic case. Put 1 to 5 in B1:F1 and again in A2:A6, then write =B$1*$A2 in B2. Fill it across to F2 and down to F6. Each of the twenty-five copies still reads its top number from row 1 and its side number from column A. One formula fills the whole grid correctly.
Drag to turn. Scroll or pinch to zoom.
16Problem
B2 to C3
Hint
B$1 → C$1, $A2 → $A3.
Solution
Answer: =C$1*$A3
One right and one down: B$1 becomes C$1, $A2 becomes $A3.
17Problem
=E$1*$A5
In that table, what value does =E$1*$A5 give?
Hint
E1 is 4 and A5 is 4.
Solution
Answer: 16
E1 holds 4 and A5 holds 4: 4 × 4 = 16.
18Practice
Copy a reference with $
The helpers and the parsing are given: c$ and r$ are "$" or "". Finish shift(ref, down, right) so that a part with a $ stays and a part without one moves.
A5
$B$1
C$1
$A3const colNum = (s) => [...s].reduce((n, ch) => n * 26 + ch.charCodeAt(0) - 64, 0);
const colName = (n) => (n > 26 ? colName(Math.floor((n - 1) / 26)) : "") + String.fromCharCode(65 + ((n - 1) % 26));
function shift(ref, down, right) {
const [, c$, col, r$, row] = ref.match(/(\$?)([A-Z]+)(\$?)(\d+)/);
return ref;
}
console.log(shift("A4", 1, 0));
console.log(shift("$B$1", 1, 0));
console.log(shift("A$1", 2, 2));
console.log(shift("$A1", 2, 2));
Hint
The $ in front of the letters pins the column; the $ in front of the number pins the row.
A solution
const colNum = (s) => [...s].reduce((n, ch) => n * 26 + ch.charCodeAt(0) - 64, 0);
const colName = (n) => (n > 26 ? colName(Math.floor((n - 1) / 26)) : "") + String.fromCharCode(65 + ((n - 1) % 26));
function shift(ref, down, right) {
const [, c$, col, r$, row] = ref.match(/(\$?)([A-Z]+)(\$?)(\d+)/);
const c = c$ ? col : colName(colNum(col) + right);
const r = r$ ? row : Number(row) + down;
return c$ + c + r$ + r;
}
console.log(shift("A4", 1, 0));
console.log(shift("$B$1", 1, 0));
console.log(shift("A$1", 2, 2));
console.log(shift("$A1", 2, 2));19Explain
Common mistakes
Filling =A4*B1 down without a $.
The rate reference slides to B2, B3 and B4 along with the prices, giving 0, #VALUE! and a wrong 25 instead of three taxes.
Putting the $ on the wrong part: =A4*B$1 fills down fine, =A4*$B1 does not.
$B1 pins only the column, so the row still moves. Decide which way the formula will be copied, then pin the part that would move that way.
Typing the rate into every formula as *0.1.
It works until the rate changes. Then every copy has to be found and edited, and a missed one still looks normal.
Pressing F4 in Google Sheets outside a formula and waiting for a $.
F4 switches reference types only while you are entering a formula. Elsewhere it is one of the Redo keys.
20
Summary
- $ fixes the part after it: $A$1 both, A$1 the row, $A1 the column.
- Use $B$1 for a single input cell that every row shares.
- F4 cycles A1, $A$1, A$1, $A1 (Fn+F4 on a Mac in Google Sheets).
- Mixed references let one formula fill a whole grid.