Sub topic 8
Copying a Formula: Relative and Absolute References
This chapter assumes you can enter a formula that starts with =, use cell references such as B2 in a formula, and read the order of operations. You will learn what happens to a reference when you copy a formula, and how to stop a reference from moving.
Why copying matters
A price list often has dozens of rows that need the same calculation. You write the formula once, then copy it down the column. Excel does not copy the formula text exactly. It adjusts the cell references so each row calculates with its own data. This works well when you expect it. It causes wrong results when you don't.
Relative references
A relative reference is a cell address that Excel shifts when you copy the formula to another cell. Excel stores the reference as an offset from the formula's own cell. For example, B2 in cell D2 means "two columns to the left, same row."
Suppose B2 holds a unit price and C2 holds a quantity. In D2 you enter this formula:
=B2*C2Copy D2 to D3. The formula in D3 becomes =B3*C3. Copy it to D4 and it becomes =B4*C4. Each row multiplies its own price by its own quantity.
To copy down a column, select the cell, then drag the small square at its bottom-right corner (the fill handle) down over the target cells. You can also press Ctrl+C on the cell, select the target cells, and press Ctrl+V.
The problem with a shared value
Now add a tax rate. Put 8% in F1. You want each row to add tax to its price. A first attempt might be:
=B2*(1+F1)This returns the correct result in row 2. Copy it to row 3 and Excel shifts every relative reference down one row. The formula becomes =B3*(1+F2). Cell F2 is empty, so Excel treats it as 0 and the tax disappears. In row 4 the formula points at F3, and so on.
The price reference should move. The tax rate reference should stay put. You need a way to tell Excel which is which.
Absolute references
An absolute reference is a cell address that does not change when you copy the formula. You make a reference absolute by putting a dollar sign $ before the column letter, the row number, or both. The dollar sign locks the part that follows it.
=B2*(1+$F$1)Here B2 is relative and $F$1 is absolute. Copy this formula to D3 and it becomes =B3*(1+$F$1). Every row uses the tax rate in F1. If you later change F1 to 10%, all rows update.
This also keeps the rate in one visible cell, instead of typing 0.08 into every formula.
Typing the dollar signs with F4
You do not need to type the $ characters by hand. While editing a formula, click inside a reference such as F1 and press F4. Each press cycles through four forms:
| You press F4 | Reference | Meaning |
|---|---|---|
| Once | `$F$1` | Column and row both locked |
| Twice | `F$1` | Row locked, column can move |
| Three times | `$F1` | Column locked, row can move |
| Four times | `F1` | Fully relative again |
On some laptops you need to hold the Fn key as well. The last two rows of the table are mixed references. They are useful in grids, such as a multiplication table, where one value should stay fixed along a row and another along a column. For a single column of results, $F$1 is the form you will use most.
What gets copied in which direction
Copying moves references by the same distance as the formula moved. If you copy a formula one column to the right, relative column letters shift by one. If you copy it two rows down, relative row numbers shift by two. A locked part, marked with $, does not shift.
Common mistakes
- Locking the wrong reference. If
$B$2is in the formula, every row uses row 2's price. Lock only the cells that are shared. - Forgetting to lock. Results that look right in the first row and wrong below it usually mean a missing
$. - Not checking a copied row. After copying, click a cell near the bottom and read its formula in the formula bar. Confirm that each reference points where you meant.
Moving a cell with cut and paste is different from copying. Cut and paste keeps the formula exactly as written, so references do not shift.
Exercises
Exercise
B2 holds 50, F1 holds 10%, and D2 contains =B2*(1+F1). You copy D2 to D5. What formula does D5 contain, and how would you change D2 first so the copy still uses the rate in F1?
Show answer
D5 contains =B5*(1+F4), because both relative references move down three rows. Change D2 to =B2*(1+$F$1) before copying. Then D5 contains =B5*(1+$F$1).
Exercise
D2 contains =B2*C2. You copy it to E4. What formula does E4 contain?
Show answer
E4 contains =C4*D4. The formula moved one column right and two rows down, so each relative reference shifts one column right and two rows down.