Sub topic 3
Relative references: formulas that follow their position
This chapter assumes you can open a Google Sheets spreadsheet, type values into cells, and use the basic operators +, -, *, and /. It also assumes you know that a formula starts with = and that a cell has an A1-style name such as B2. Here you will learn what a relative reference is, how Sheets stores it, and how to predict what it does when the formula moves.
What a relative reference is
A relative reference is a cell address written in plain A1 form, with no $ signs. Examples are B2, C7, and the range B2:B10. Every plain reference you type is relative. You don't have to ask for it.
Suppose cell D2 holds the formula below. Column B holds a quantity and column C holds a unit price.
=B2*C2You can read this formula in two ways:
- "Multiply the value in B2 by the value in C2."
- "Multiply the cell two columns to my left by the cell one column to my left, both in my own row."
The second reading is the one Sheets uses. A relative reference describes where a cell is in relation to the formula's own cell, not where it is on the grid. That is why these references are called relative.
The working model: offsets
Sheets treats each relative reference as an offset from the cell that holds the formula. An offset has two parts: how many columns to move and how many rows to move.
| Formula cell | Reference written | Offset stored |
|---|---|---|
| D2 | B2 | 2 columns left, 0 rows |
| D2 | C2 | 1 column left, 0 rows |
| D3 | B3 | 2 columns left, 0 rows |
| D3 | C3 | 1 column left, 0 rows |
The formulas in D2 and D3 look different (=B2*C2 and =B3*C3). The offsets are identical, so they are the same instruction applied at two positions.
This offset model is the one thing to hold onto. Every behavior in this chapter follows from it.
Why this is the default
Spreadsheets usually repeat one calculation down a column or across a row. A list of orders needs a total for each order, and a list of months needs a change from the previous month. If every reference pointed at one fixed cell, you would have to retype the formula for each row. Because references are relative, you write the formula once for the first row and reuse it. The next chapter covers the mechanics of copying and filling. This chapter covers what the references mean, so you can predict the result.
A worked example: line totals
Here is a small order sheet.
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | Item | Quantity | Unit price | Line total |
| 2 | Pens | 10 | 1.50 | |
| 3 | Notebooks | 4 | 3.25 | |
| 4 | Staplers | 2 | 8.00 |
Click D2 and type:
=B2*C2D2 shows 15. Now picture the same formula in D3 and D4. The offsets stay the same, so each row works on its own data:
- D3 holds
=B3*C3, which is 13. - D4 holds
=B4*C4, which is 16.
You wrote the formula once. The only thing that differs between rows is the position it sits in.
Pointing instead of typing
While you edit a formula, you can click a cell instead of typing its address. Sheets inserts the reference for you, and it draws a colored border around the referenced cell. Each reference in the formula gets its own color. If you see a border on a cell you did not intend, the formula points at the wrong place.
Predicting a shifted formula
The rule is short. When a formula moves to a new position, every relative reference moves by the same distance:
- Moving down by n rows adds n to every row number.
- Moving right by n columns shifts every column letter forward by n letters.
- Moving up or left subtracts instead.
Take =B2*C2 in D2 and apply the rule:
| New position | Move from D2 | Resulting formula |
|---|---|---|
| D3 | 1 row down | `=B3*C3` |
| D10 | 8 rows down | `=B10*C10` |
| E2 | 1 column right | `=C2*D2` |
| F5 | 2 columns right, 3 rows down | `=D5*E5` |
The E2 row deserves a second look. The formula moved right, so both references moved right, and it now multiplies C2 by D2. That is correct under the rule, but it is rarely what you want. It is a reminder that the references follow the formula in both directions, not just down.
Relative references in ranges
A range such as B2:B10 is two relative references joined by a colon. Both ends are relative, and both shift together. Consider this formula in B11, which totals the column above it:
=SUM(B2:B10)If this formula is copied one column to the right into C11, it becomes =SUM(C2:C10). Each end moved one column right. The size and shape of the range stay the same. That is useful for column totals across a wide table. The same shift can break a formula that was meant to sum a fixed block, as the next section shows.
Common errors
A reference that should stay put drifts
Say you keep a tax rate in F1 and write this in D2:
=B2*F1D2 works. Fill it down to D3 and you get =B3*F2. F2 is empty, so the result is 0, with no error message. Nothing looks broken, but every row below the first is wrong. This is the most common mistake with relative references. The cure is an absolute reference, which is the topic of a later chapter. For now, learn to spot the symptom: a calculation that is right in the first row and quietly wrong below it.
Moving off the edge of the sheet
A relative reference has to land on a real cell. Put =A1 in B2. The reference points one column left and one row up. Now copy that formula into B1. It would need to point at row 0, which does not exist, so the cell shows #REF!. The general rule is that a relative reference pointing above row 1 or left of column A after a copy produces a #REF! error. The later chapter on reference errors covers fixing these.
Copying and cutting are different
Copying a formula and pasting it re-aims the relative references, as described above. Cutting and pasting does not. If you cut D2 and paste it into F2, the formula still reads =B2*C2 and keeps pointing at the same cells. Use cut when you want to relocate a formula without changing what it calculates. Use copy when you want a new formula that follows its new position.
Inserting and deleting rows
If you insert a row inside the data a formula refers to, Sheets updates the reference so that it still points at the same cells. A formula =B2*C2 becomes =B3*C3 if you insert a row above row 2, because the data it refers to moved down. If you delete the row that holds a referenced cell, the reference cannot be kept, and the formula shows #REF!.
The first formula is wrong everywhere
Because one formula is reused, a mistake in the first cell is repeated in every cell filled from it. Check the first formula carefully before reusing it.
A previous-row reference
Relative offsets also let a formula refer to a different row from its own. A running balance is a good example. Put an opening balance in C2 and a transaction amount in B3, then write this in C3:
=C2+B3C3 adds the cell one row above it (C2) to the amount in its own row (B3). Filled down, C4 holds =C3+B4, C5 holds =C4+B5, and so on. Each balance builds on the one before it. This works only because the references are relative. A fixed address could not express "the row above me".
Exercise
Cell E4 holds =B4+C4*D4. You copy it to G7. Write the formula that G7 will contain, and explain how you got it.
Show answer
G7 holds =D7+E7*F7. G7 is 2 columns right and 3 rows down from E4. Every relative reference moves by the same amount, so B becomes D, C becomes E, D becomes F, and each row number 4 becomes 7.
Exercise
In D2 you write =B2*F1, where F1 holds a tax rate, and fill it down to D3. What formula does D3 contain, why is the result likely wrong, and what kind of reference would fix it?
Show answer
D3 contains =B3*F2. F1 is a relative reference, so it moved down one row along with B2, and it now points at the empty cell F2. The result is 0 and no error appears. An absolute reference to F1 would keep it fixed in place.