Sub topic 10
Copying formulas with relative and absolute references
This chapter assumes you can enter formulas that start with =, select ranges, and use SUM, AVERAGE, MIN, MAX, and COUNT on a single range. It explains what Excel does to the cell addresses inside those formulas when you copy, fill, or drag them. It also shows how to control that behavior.
What a reference really stores
When you type =SUM(B2:B6) in cell B7, Excel does not remember "column B, rows 2 to 6" as fixed addresses. By default it remembers a position relative to the formula cell: "the five cells directly above me." This is a relative reference.
Copying the formula moves that relationship with it. Copy B7 to C7 and Excel rewrites the formula to match the new location:
=SUM(B2:B6)
=SUM(C2:C6)The first formula is in B7. The second is the copy in C7, with each address shifted one column to the right. This is why you can write one total, drag it across a row of columns, and get a correct total for each.
The same applies to fill-down, fill-right, and copy and paste. Excel shifts the row and column parts of every relative reference by the same distance you moved the formula.
A worked example: totals and averages across columns
Suppose a sheet holds monthly sales for three regions:
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | Month | East | West | North |
| 2 | Jan | 120 | 90 | 75 |
| 3 | Feb | 130 | 85 | 80 |
| 4 | Mar | 110 | 95 | 70 |
| 5 | Apr | 140 | 100 | 85 |
| 6 | May | 125 | 105 | 90 |
In B7 enter the formulas for the East column, then drag the fill handle (the small square at the bottom-right corner of the selected cell) across to D7:
=SUM(B2:B6)
=AVERAGE(B2:B6)
=MIN(B2:B6)
=MAX(B2:B6)
=COUNT(B2:B6)If these sit in B7:B11, selecting that block and dragging right fills C7:D11. Each cell now points at its own column. In D9, for example, the formula is =MIN(D2:D6).
Relative references are the right default here, because every column needs its own range.
When relative references break
Relative behavior becomes a problem when part of the formula must stay put. A common case is a percent-of-total column. Suppose the East values are in B2:B6 and you want each month's share of the total in column E.
Your first attempt might be:
=B2/SUM(B2:B6)This gives the right answer in E2. Fill it down and Excel shifts both the numerator and the SUM range:
| Cell | Formula after fill-down | What it divides by |
|---|---|---|
| E2 | `=B2/SUM(B2:B6)` | Total of Jan to May (correct) |
| E3 | `=B3/SUM(B3:B7)` | Total of Feb to May plus blank B7 |
| E4 | `=B4/SUM(B4:B8)` | Total of Mar to May plus two blanks |
| E5 | `=B5/SUM(B5:B9)` | Total of Apr and May plus blanks |
Nothing shows an error. SUM ignores blanks, so the formulas return plausible but wrong percentages. This is the main danger of relative references: the failure is silent.
Anchoring with the dollar sign
A dollar sign in front of a column letter or row number tells Excel not to shift that part when the formula is copied. The fix for the percent-of-total column is:
=B2/SUM($B$2:$B$6)Now $B$2:$B$6 is an absolute reference. Fill it down and the SUM range stays fixed while B2 still advances to B3, B4, and so on.
A reference can be anchored in four ways:
| Style | Example | Column when copied sideways | Row when copied down |
|---|---|---|---|
| Relative | `B2` | Shifts | Shifts |
| Absolute | `$B$2` | Fixed | Fixed |
| Mixed, row locked | `B$2` | Shifts | Fixed |
| Mixed, column locked | `$B2` | Fixed | Shifts |
You can type the dollar signs yourself. A faster way is to put the cursor in or next to the reference and press F4 (on some laptops Fn+F4). Each press cycles through B2, $B$2, B$2, $B2, and back.
Anchoring with the summary functions
Several patterns come up repeatedly with SUM, AVERAGE, MIN, MAX, and COUNT.
Compare each value to a fixed statistic
To show how far each month is from the East average:
=B2-AVERAGE($B$2:$B$6)Fill down and each row subtracts the same average. The same pattern works with MIN and MAX. This scales each value to a 0-to-1 range:
=(B2-MIN($B$2:$B$6))/(MAX($B$2:$B$6)-MIN($B$2:$B$6))If the range is all one value, MAX minus MIN is zero and the result is #DIV/0!. The earlier chapter on guarding formulas covers how to handle that.
Running totals with a mixed anchor
A running total needs the start of the range fixed and the end moving. Lock only the first cell:
=SUM($B$2:B2)In C2 this adds just B2. Fill down to C3 and the formula becomes =SUM($B$2:B3), then =SUM($B$2:B4), and so on. The range grows by one row each time. The same shape works for a running average with AVERAGE($B$2:B2) or a running maximum with MAX($B$2:B2).
Copy across a table using one fixed row or column
Suppose a lookup value in a cell, such as a threshold in G1, is used by every formula in a block. Locking it with $G$1 keeps every copy pointing at that one cell. If instead each row has its own threshold in column G, use $G2. The column stays on G, and the row advances with each copy.
The diagram below summarizes how to choose.
Copy versus cut
Only copying rewrites references. Cut and paste (or dragging a cell by its border) moves the formula and leaves its references unchanged. If B7 contains =SUM(B2:B6) and you cut it to F10, F10 still reads =SUM(B2:B6).
Cutting a cell that other formulas point to is also safe. Excel updates those formulas to follow the moved cell. Use cut when you want the formula to keep its meaning, and copy when you want a new instance that adapts to its location.
Common errors and edge cases
- Silent range drift. As in the percent example, a range that slides past the data returns a wrong value, not an error. When you fill down a formula that uses a summary function, click a cell near the bottom and check its range.
#REF!after copying. If a relative reference would move before column A or row 1, Excel cannot represent it and the copy shows#REF!. Copying=SUM(A1:A3)from B5 to B2 is an example, because the range would need rows above row 1.- Whole-column references.
=SUM(B:B)is relative on the column part, so copying it to C changes it toC:C. Write$B:$Bif the column must stay fixed. - Totals inside the range. If you fill a subtotal formula into a row that lies inside its own range, Excel reports a circular reference. Keep the total outside the data it sums.
- Inserting rows. Rows inserted inside
$B$2:$B$6expand the range, and absolute references adjust for inserted rows as well. A row inserted directly below row 6 is outside the range and is not included. Leave a spare row or use a table (Ctrl+T) if data grows at the bottom. - Absolute does not mean frozen. Dollar signs only control how copying changes the address. Inserting, deleting, or moving cells can still change an absolute reference.
- Other sheets. References such as
Sheet2!$B$2:$B$6follow the same rules. The sheet name does not change when you copy, but the cell address does unless it is anchored.
Checking your work
Press Ctrl+` (grave accent) to switch the sheet to formula view, which shows every formula as text so you can scan a filled column for a pattern that drifts. Press it again to return to values. Alternatively, select a copied cell and press F2. Excel outlines each referenced range on the sheet in color.
Exercise
Column B holds sales in B2:B6. In C2 you want each row's sales divided by the largest sale in the list, and you plan to fill the formula down to C6. Which formula do you enter in C2, and what does C4 contain afterward?
Show answer
Enter =B2/MAX($B$2:$B$6). After filling down, C4 contains =B4/MAX($B$2:$B$6). The numerator B2 is relative and advances with the row. The MAX range is absolute, so every row divides by the same maximum.
Exercise
You enter =SUM($B$2:B2) in C2 and fill it down to C5. What formula is in C5, and what does the column show?
Show answer
C5 contains =SUM($B$2:B5). The column shows a running total: each row adds all values from B2 down to the current row.