Sub topic 2
Relative references: formulas that move with you
This chapter explains the default way Excel treats a cell reference: as a position relative to the formula, not as a fixed address. Almost every filled-down formula depends on this behavior. It is also the cause of most wrong results when a formula is copied.
It assumes you can enter and edit a basic formula, select cells and ranges, and copy cells or use the fill handle (the small square at the bottom-right corner of the selected cell). The previous chapter covered how A1 notation names a cell. This chapter builds on that.
The idea: a reference is a direction, not an address
When you type =A2*B2 into cell C2, it looks as though the formula says "multiply the contents of A2 by the contents of B2". Excel stores something different. It records where the two inputs are in relation to the cell holding the formula:
- The first input is two columns to the left, in the same row.
- The second input is one column to the left, in the same row.
A reference that works this way is called a relative reference. The formula remembers directions, not destinations. When you copy the formula to another cell, Excel keeps the directions and recalculates where they lead from the new position.
| Formula location | Formula as typed | First input is | Second input is |
|---|---|---|---|
| C2 | `=A2*B2` | 2 columns left, same row | 1 column left, same row |
| C3 | `=A3*B3` | 2 columns left, same row | 1 column left, same row |
| C10 | `=A10*B10` | 2 columns left, same row | 1 column left, same row |
The text differs in each row, but the directions are identical. That is why one formula can be written once and reused down a whole column.
Filling down
Suppose column A holds quantities, column B holds unit prices, and you want line totals in column C. You type the first formula in C2:
C2: =A2*B2Then you drag the fill handle down one row, or copy C2 and paste into C3. Excel produces:
C3: =A3*B3Moving one row down added 1 to every row number in the formula. Both references moved because both were relative. If you filled down to C20, the formula in C20 would be =A20*B20.
Excel's rule for a relative reference is simple: the row and column numbers shift by the same amount as the formula itself.
- Move the formula down by n rows, and every relative row number increases by n.
- Move the formula right by n columns, and every relative column letter advances by n letters.
- Moving up or left subtracts instead.
Filling across
The rule applies to columns as well. Say rows 2 to 4 hold monthly sales for three products, with one month per column, and you want a total for each month in row 5:
B5: =SUM(B2:B4)Fill the formula right into C5 and the column letters shift by one:
C5: =SUM(C2:C4)This also shows that ranges are relative. Each end of B2:B4 is a separate cell address, and each one shifts independently by the same amount. The size and shape of the range stay the same. Only its position changes.
Seeing the model in a diagram
The diagram shows how one formula in C2 turns into the formula in C3 when filled down.
Moving in both directions at once
A copy can move across and down at the same time, and the shifts add together. Say B2 contains =A1, which points one column left and one row up. Copy B2 to C3, which is one column right and one row down. The reference still points one column left and one row up from its new home:
B2: =A1
C3: =B2You will rarely want a diagonal copy on purpose. It matters when you paste a block of formulas into a different area of the sheet. In that case every formula shifts by the same horizontal and vertical distance as the block.
Making the stored directions visible with R1C1 notation
Excel has an alternative display mode called R1C1 reference style, where the stored directions appear in the formula. You can switch it on at File > Options > Formulas by ticking "R1C1 reference style". In that mode, the formula in C2 that you wrote as =A2*B2 is displayed like this:
=RC[-2]*RC[-1]Read it as follows:
Rwith no number means "the same row as this cell".C[-2]means "the column 2 to the left".C[-1]means "the column 1 to the left".
Square brackets mean a relative offset. Every cell in the filled column shows exactly this same text, which is a clear confirmation that the formulas are really one formula repeated.
This is a diagnostic tool, not something you need to work in daily. Switching it on when a column behaves strangely is a quick way to find a cell whose formula differs from its neighbors, because the odd one out displays different text. Switch it back off when you are done so your sheet matches what colleagues expect to see.
Ways to copy a relative formula
All of these methods adjust relative references in the same way. They differ only in convenience.
| Method | What it does |
|---|---|
| Drag the fill handle | Copies the formula into every cell you drag across. |
| Double-click the fill handle | Fills down as far as the adjacent column has data, then stops. |
| Ctrl+D | Fills the top cell of a selection down into the rest of the selected cells. |
| Ctrl+R | Fills the leftmost cell of a selection right into the rest of the selected cells. |
| Copy and paste | Copies to any destination, including cells far from the original. |
Double-clicking the fill handle uses the neighboring column to decide where to stop. If that column has a blank cell partway down, the fill stops there. If your data has gaps, check that the fill reached the last row.
Where relative references go wrong
Relative references are the default because they suit most calculations. They fail when part of a formula should stay fixed while the rest moves. The most common case is a single input cell that every row has to use.
Suppose the tax rate is in E1, prices are in column B, and you want the tax for each row in column D. You type this in D2, where it works correctly:
D2: =B2*E1Then you fill down. Both references are relative, so both move down:
D3: =B3*E2
D4: =B4*E3D3 now multiplies by E2, which is probably empty. An empty cell counts as zero in arithmetic, so D3 shows 0 and no error appears. That is the dangerous part. The first row is right, the next rows are silently wrong, and nothing on the sheet warns you.
This is the pattern to learn to recognize: the first result is correct and the rest look plausible or show zeros. The fix is to lock the reference to E1 so it does not move, which is the subject of the next chapter. For now, remember that a relative reference to a fixed input is almost always a mistake.
Edge cases
Running off the edge of the sheet
A relative reference can lead to a cell that does not exist. Suppose A2 contains =A1 (one row up), and you copy it to a cell in row 1. The reference would need row 0, which cannot exist. Excel shows #REF! in the destination:
A2: =A1Copying A2 to row 1 gives the #REF! error, because there is no row above row 1. The same applies in columns: a formula pointing one column left cannot be pasted into column A.
Blank cells and text
A relative reference that lands on a blank cell is treated as 0 in arithmetic. That is why a formula can quietly return 0 instead of failing. A reference that lands on text, such as a heading, makes arithmetic return #VALUE!. For example, if =B2*E1 is filled upward into row 1, one of the inputs could become a text label and return #VALUE!.
Functions such as SUM ignore text and blanks inside a range, so a SUM over shifted ranges often hides the problem rather than showing it.
Ranges that shift out of alignment
When a formula contains several ranges, they should stay the same size and move together. In =SUM(B2:B4) both ends are relative, so they shift together and the range stays three cells tall. If you edit only one end by hand in a single cell, that cell is now different from its neighbors, and the next fill propagates the odd range.
Filling is not the same as moving
Everything in this chapter describes copying and filling. Cutting a formula and pasting it elsewhere behaves differently: it keeps pointing at the same cells it did before. How cut, insert, and delete affect references is covered in a later chapter. The point to carry forward is that the adjustment rule here applies when the formula is copied, not when it is moved.
Debugging a filled formula
When a column of relative formulas gives odd results, work through these checks in order:
- Press Ctrl+` (the backtick key, usually under Esc) to show formulas instead of values. Scan the column for any cell whose text pattern breaks from its neighbors.
- Click the first suspicious cell and press F2. Excel outlines each referenced cell with a colored border, so you can see which cells the formula actually reads.
- Compare the references in the first row with those in the last. If an input that should be shared has crept downward, such as E1 turning into E2 and E3, you have found a reference that needed to be fixed.
- Use Formulas > Trace Precedents to draw arrows from the cells a formula depends on.
- Switch on R1C1 style temporarily. All correct cells in a filled column show identical text, so any different cell stands out immediately.
Trying this on a small example is the fastest way to build the habit. Create a column of three products with quantities and prices, fill the line total formula, and then check each of the five steps above. You should see the same RC[-2]*RC[-1] pattern in all three rows.
Summary
- A relative reference stores a direction from the formula's own cell, not a fixed address.
- When a formula is copied or filled, every relative reference shifts by the same number of rows and columns as the formula.
- Ranges are relative as well: each end shifts independently by the same amount.
- Relative references are the right choice when each row or column uses its own inputs. They are the wrong choice for a value that every row must share.
- R1C1 style, Show Formulas, and F2 make the stored directions visible when you need to debug.
Exercise
Cell C2 contains =A2*B2. You copy C2 and paste it into E5. What formula does E5 contain, and why?
Show answer
E5 contains =C5*D5. E5 is 2 columns to the right of C2 and 3 rows below it. Every relative reference shifts by that same amount: A2 becomes C5 (A plus 2 columns is C, row 2 plus 3 is row 5), and B2 becomes D5.
Exercise
Prices are in B2:B10 and the tax rate is in E1. You enter =B2*E1 in D2 and fill down to D10. D2 is correct. What formula is in D4, what value will it probably show if E3 is empty, and why does Excel not report an error?
Show answer
D4 contains =B4*E3. Both references are relative, so both moved down two rows. If E3 is empty, Excel treats it as 0, so the result is 0. No error appears because multiplying by a blank cell is valid arithmetic. The fix is to keep E1 from shifting, which the next chapter covers with absolute references.
Exercise
A cell in A2 contains =A1. You copy it to B1. What happens, and why?
Show answer
B1 shows #REF!. The formula points one row up from its own cell. In row 1 there is no row above, so the shifted reference does not exist.