Sub topic 5
Absolute references with $ to pin a cell
This chapter assumes you can enter values and formulas in Google Sheets, use A1 notation (such as B2), and understand that a relative reference changes when a formula is copied or filled. Here you will learn how to stop a reference from changing by pinning it with $.
The problem: a reference that drifts
A relative reference follows its position. If you write a formula in D2 that points at a cell to its left, and then fill it down, every row gets its own version of the formula. This is what you want for values that change per row, such as quantity and price.
It becomes a problem when one input is shared by every row. Suppose column B holds prices, and cell F1 holds a tax rate of 0.2. You want the tax for each row. The obvious first attempt looks like this:
=B2*F1This gives the right answer in row 2. When you fill it down to row 3, both references move down one row:
=B3*F2F2 is empty, so the result is 0. The price reference moved correctly, but the tax rate reference also moved. You need a way to say "this reference never changes."
The $ sign
Putting a dollar sign in front of a column letter or a row number locks that part of the reference. A reference with both parts locked is an absolute reference.
=B2*$F$1When this formula is filled down, B2 becomes B3, B4, and so on, but $F$1 stays exactly as written. Every row multiplies its own price by the one tax rate in F1.
Read $F$1 as two separate locks:
$Flocks the column. The reference always uses column F.$1locks the row. The reference always uses row 1.
The dollar sign has nothing to do with currency. It is only a marker that means "do not adjust this part."
Comparing the reference types
The table below shows what happens to each form of reference when the formula that contains it is copied one column to the right and one row down.
| Written as | Type | After copying right 1 and down 1 |
|---|---|---|
| `B2` | Relative | `C3` |
| `$B$2` | Absolute | `$B$2` |
| `$B2` | Mixed (column locked) | `$B3` |
| `B$2` | Mixed (row locked) | `C$2` |
Mixed references get their own chapter. For now, focus on the first two rows of the table. A relative reference moves in both directions, and an absolute reference moves in neither.
Worked example: price with tax
Set up a sheet like this. Cell F1 holds the tax rate, and E1 holds a label for it.
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | Item | Price | Qty | Total with tax |
| 2 | Pen | 2.50 | 10 | |
| 3 | Notebook | 4.00 | 5 | |
| 4 | Stapler | 9.00 | 2 |
Put the tax rate 0.2 in F1. Then enter this formula in D2:
=B2*C2*(1+$F$1)Fill D2 down to D4. The formulas become:
- D2:
=B2*C2*(1+$F$1)gives 30 - D3:
=B3*C3*(1+$F$1)gives 24 - D4:
=B4*C4*(1+$F$1)gives 21.6
B and C move down with the row, while $F$1 stays put. If the tax rate changes to 0.25, you edit F1 once and every total updates.
This is the main reason to use absolute references. A constant such as a rate, a threshold, or an exchange rate belongs in one labeled cell, not typed into each formula. Typing 1.2 into every formula is called hardcoding. It hides the assumption and forces you to edit every formula when the value changes.
Typing $ and using F4
You can type the dollar signs by hand. A faster way is to place the cursor on or inside a reference while editing a formula and press F4 (on Mac, Cmd+T in some setups, or Fn+F4 on laptops where function keys are shared). Each press cycles through the four forms:
F1, relative$F$1, absoluteF$1, row locked$F1, column locked
Then the cycle repeats. If the shortcut does nothing in your browser, type the $ characters directly. Also check that the cursor is touching the reference you want to change, since the shortcut acts on the reference at the cursor.
Why copy and move behave differently
Absolute references protect you when a formula is copied or filled. They do not protect the target cell itself in every situation.
Keep these behaviors apart:
- Copy and paste, or fill: the formula is re-written relative to its new position. Relative parts shift, and
$parts do not. - Cut and paste (move): the formula is moved unchanged, and its references keep pointing at the same cells. Dollar signs make no difference here.
- Moving the cell a formula points at: if you cut F1 and paste it into G1, formulas that referred to F1 are updated to refer to G1. This happens whether or not they used
$. - Inserting or deleting rows and columns: references adjust so they follow the cell they pointed at. An absolute reference
$F$1becomes$G$1if you insert a column before F. The$means "do not change on copy," not "never change at all."
Edge cases and common mistakes
Pinning too much
If you write $B$2 where you meant B2, the first row looks right and every other row repeats the first row's value. The symptom is a column of identical results. Check that only the cells that should be shared are locked.
Pinning too little
If you forget the $, the symptom is the opposite. Results are correct in the first row, then wrong, zero, or blank in later rows. Click into one of the later formulas and look at which references drifted. A reference to an empty cell often produces 0, and a reference that drifted into text can produce #VALUE!.
Pinning a range
Ranges can be absolute too. Both ends need locking:
=B2/SUM($B$2:$B$10)This calculates each row's share of the total. Without the dollar signs, the range would slide down as you fill, and the total would shrink or point at the wrong cells. A common error is locking only one end, such as $B$2:B10. The start stays fixed while the end moves, which is sometimes useful, as in a running total, and sometimes a bug.
A running total uses this on purpose:
=SUM($B$2:B2)In row 2 this adds B2. In row 3 it becomes =SUM($B$2:B3), which adds B2 and B3, and so on. The start is pinned and the end follows the row.
A pinned cell that holds the wrong thing
An absolute reference only controls where the formula looks. If F1 contains text such as "20%" typed with a stray space, or is empty, the formulas return #VALUE! or a result of 0. Format the input cell as a number or percent and keep one value in it.
Dividing by a pinned cell
If a pinned cell is empty or zero and you divide by it, you get #DIV/0!. For example, =B2/$F$1 fails if F1 is blank. Fix the input cell first. If blanks are expected, guard the formula:
=IF($F$1=0, "", B2/$F$1)A blank cell compares equal to 0 here, so this returns an empty string when F1 is blank or zero.
Absolute references across sheets
Locking works the same way when the pinned cell is on another sheet. If a sheet named Settings holds the tax rate in B1, use:
=B2*C2*(1+Settings!$B$1)The $ signs go on the cell part, after the !. A sheet name containing spaces needs quotes, as in 'Tax Settings'!$B$1. This is a clean pattern for keeping all your inputs on one sheet.
Choosing absolute or relative
Ask this question for each reference in the formula: when this formula is filled to another row or column, should this reference follow along, or should it stay on the same cell?
- Follows along: leave it relative.
- Stays on one cell in both directions: use
$on the column and the row. - Stays in one direction only: use a mixed reference, covered in a later chapter.
Test your choice by filling the formula into two or three cells and clicking into each one. It takes a few seconds and catches most mistakes before they reach a report.
Exercises
Exercise
Cell G1 holds a discount rate of 0.1. Column B holds prices starting in B2. You write =B2*(1-G1) in C2 and fill it down to C5. What formula appears in C4, and what result do you expect? How do you fix it?
Show answer
C4 contains =B4*(1-G3). G3 is empty, so it counts as 0 and C4 just equals B4, with no discount applied. Fix it by pinning the rate: =B2*(1-$G$1) in C2, then fill down again. C4 becomes =B4*(1-$G$1).
Exercise
You want column D to show each value in B2:B10 as a share of the column total. A colleague writes =B2/SUM(B2:B10) in D2 and fills down. Why do the results go wrong, and what is the corrected formula?
Show answer
Both ends of the range are relative, so in D3 the range becomes B3:B11 and the total no longer includes B2. Pin the range: =B2/SUM($B$2:$B$10). The numerator B2 stays relative so each row uses its own value.
Exercise
Write a formula for C2 that gives a running total of column B starting at B2, so that C4 equals B2+B3+B4.
Show answer
=SUM($B$2:B2). The start is pinned to B2 and the end is relative, so in C4 it becomes =SUM($B$2:B4).