Sub topic 4
What happens when you copy or fill a formula
This chapter assumes you can open a Google Sheets spreadsheet, type values into cells, and use the arithmetic operators +, -, *, and /. It also assumes you know A1 notation (such as B2) and the idea of a relative reference, both covered in earlier chapters. Here you will learn exactly how a formula changes when you copy it, fill it, or move it, and how to predict the result before you do it.
The core rule: references are stored as offsets
A reference like B2 in a formula is not a fixed address. Sheets treats a plain reference as a relative one. It remembers where the target cell sits compared with the cell that holds the formula.
Suppose D2 contains =B2*C2. From D2, the cell B2 is two columns to the left and on the same row. C2 is one column to the left and on the same row. When you copy the formula to another cell, Sheets keeps those offsets and rebuilds the references from the new position.
=B2*C2If you copy D2 to D3, the formula moves one row down. Both references move one row down with it, so D3 contains =B3*C3. If you copy it to E2, it moves one column right, so E2 contains =C2*D2.
| Formula cell | Formula | Offset of first reference |
|---|---|---|
| D2 | `=B2*C2` | 2 columns left, same row |
| D3 | `=B3*C3` | 2 columns left, same row |
| D4 | `=B4*C4` | 2 columns left, same row |
| E2 | `=C2*D2` | 2 columns left, same row |
The formula's meaning ("multiply the two cells to my left") stays the same. Only the literal addresses change.
Ways to copy a formula
Several actions produce the same adjustment, and a few do not. Knowing which is which prevents surprises.
- Fill down or right with the fill handle. Select the cell, then drag the small square at its bottom-right corner. Sheets writes an adjusted copy into each cell you pass over.
- Double-click the fill handle. Sheets fills down as far as the neighboring column has data. It stops at the first blank cell in that neighboring column.
- Keyboard fill. Select the source cell plus the target cells below it, then press Ctrl+D (Cmd+D on Mac) to fill down. Use Ctrl+R (Cmd+R) to fill right.
- Copy and paste. Press Ctrl+C on the source and Ctrl+V on the target. References adjust by the distance between the two cells.
- Paste formula only. Use Paste special, then Paste formula only. The formula adjusts, but formatting from the source is not carried over.
- Paste values only. This pastes the result of the formula, not the formula, so nothing adjusts. The pasted cell holds a plain number or text.
The following diagram shows how one formula is rewritten as it is filled down.
Moving is different from copying
Cutting and pasting a formula cell (Ctrl+X, then Ctrl+V) does not rewrite the formula's own references. If D2 contains =B2*C2 and you cut it and paste it into G10, the formula in G10 is still =B2*C2. Sheets assumes you want the same calculation in a new place.
The opposite case matters too. If you cut and paste a cell that other formulas point at, those formulas follow the cell to its new location. Say D2 contains =B2*C2 and F5 contains =D2+1. After you move D2 to G10, the formula in F5 becomes =G10+1.
When a fixed value gets shifted
Relative adjustment becomes a problem when one input should stay in one place. Imagine a tax rate in F1, and prices in column B. You write this in C2:
=B2*F1Fill it down to C3 and you get =B3*F2. The reference to B should move, but the reference to F1 should not. F2 is empty, so the result is 0, with no error message. This is a silent failure, which makes it dangerous.
The fix is an absolute reference, which uses $ to pin the cell. The next chapter covers it fully. A quick preview:
=B2*$F$1When this is filled down, B2 becomes B3, B4, and so on, while $F$1 stays as $F$1.
Predicting the result: a worked example
Try this on a blank sheet. Enter these values.
| Cell | Value |
|---|---|
| A1 | Item |
| B1 | Price |
| C1 | Quantity |
| D1 | Total |
| A2 | Pen |
| B2 | 2 |
| C2 | 10 |
| A3 | Book |
| B3 | 12 |
| C3 | 3 |
| A4 | Bag |
| B4 | 30 |
| C4 | 2 |
In D2, type =B2*C2 and press Enter. Select D2, then double-click the fill handle. Because column C has data in rows 2 to 4, Sheets fills D3 and D4. Click each cell to check its formula.
| Cell | Formula | Result |
|---|---|---|
| D2 | `=B2*C2` | 20 |
| D3 | `=B3*C3` | 36 |
| D4 | `=B4*C4` | 60 |
Now copy D2 and paste it into F2. The destination is two columns to the right, so each reference shifts two columns right. The pasted formula is =D2*E2. E2 is empty, so the result is 0. That is the correct result for the offset, even if it is not what you wanted.
Filling in different directions
The direction of the fill decides which part of the reference changes.
- Filling down changes row numbers:
B2becomesB3. - Filling right changes column letters:
B2becomesC2. - Filling up or left changes them in the opposite direction:
B2becomesB1orA2. - A diagonal copy changes both the row and the column.
Going past the edge of the sheet causes trouble. If B1 has the formula =A1 and you copy it one column to the left into A1, the reference would need to point at a column left of A. That cell does not exist, so the pasted formula shows #REF!. The same happens if a copy would need a row above row 1.
Ranges adjust the same way
A range such as B2:B10 is two references joined by a colon. Both ends shift together.
=SUM(B2:B10)If this is in B11 and you copy it to C11, it becomes =SUM(C2:C10). This is why a total row copied across a table sums each column. The range keeps its size and moves as a block.
Be careful when you fill a range-based formula down. If E2 contains =SUM(B2:B4) and you fill down, E3 becomes =SUM(B3:B5). The window slides by one row each time. This is useful for running windows, but it is a common mistake when you wanted a fixed range, such as a grand total. In that case pin the range: =SUM($B$2:$B$4).
Inserting and deleting rows
Copying is not the only operation that changes references. Inserting or deleting rows and columns also rewrites formulas.
- Inserting a row inside a range expands the range. If
=SUM(B2:B10)has a row inserted between rows 4 and 5, it becomes=SUM(B2:B11). - Inserting a row above the first row of a range shifts the range down:
B2:B10becomesB3:B11. - Deleting a row inside a range shrinks it.
- Deleting a cell that a formula points at directly produces
#REF!, because the target no longer exists.
Common mistakes and how to spot them
- Filling a formula that needs a fixed input. Symptoms are zeros or wrong values that grow worse down the column. Click a cell near the bottom and read its formula. If a reference you expected to stay put has drifted, you need a
$. - Pasting into the wrong offset. A pasted formula points at cells you did not intend. Click the cell and check its references against the offset rule.
- Pasting values by accident. The cells show correct numbers but do not update when inputs change. Click one: if the formula bar shows a plain number, the formula was lost.
- Copying past the sheet edge. The result is
#REF!. Copy from a cell with more room, or rewrite the formula. - Sliding a range you meant to fix. Totals are too small or include the wrong rows. Pin the range with
$.
A fast way to audit a filled column is to select the whole column of formulas and press Ctrl+` (the grave accent key) to show formulas instead of values. Every formula becomes visible at once, so inconsistent ones stand out. Press the same keys again to switch back.
Quick reference
| Action | Does the formula's own text change? | Do references adjust? |
|---|---|---|
| Fill down, right, up, or left | Yes | Yes, by the fill distance |
| Copy and paste | Yes | Yes, by the paste distance |
| Cut and paste | No | Formulas pointing at the moved cell follow it |
| Paste values only | Formula is replaced by its result | Not applicable |
| Insert or delete rows | Only when affected cells shift | Yes, ranges expand, shrink, or shift |
Exercise
Cell E5 contains =C3+D4. You copy E5 and paste it into G8. What formula does G8 contain, and why?
Show answer
G8 contains =E6+F7. G8 is two columns right and three rows down from E5, so every reference moves two columns right and three rows down. C3 becomes E6, and D4 becomes F7.
Exercise
Column B holds prices, and cell F1 holds a discount rate. In C2 you wrote =B2*F1 and filled it down to C20. The values in C3 to C20 are all 0. Why, and what formula in C2 fixes it?
Show answer
Relative references shift when filled, so C3 contains =B3*F2, C4 contains =B4*F3, and so on. Those cells are empty, which gives 0. Pin the discount cell with $, writing =B2*$F$1 in C2, then fill down again.
Exercise
You cut cell D2, which contains =B2*C2, and paste it into G10. What does G10 contain? If F5 contained =D2+1 beforehand, what does F5 contain afterward?
Show answer
G10 still contains =B2*C2, because cut and paste does not adjust the moved formula's references. F5 becomes =G10+1, because formulas that point at a moved cell follow it.