Sub topic 4
Calculating with Cell References Instead of Typed Numbers
What this chapter assumes
This chapter assumes you can do the following:
- Open a workbook and select a cell.
- Type a value into a cell and press Enter.
- Start a formula with
=and use the operators+,-,*and/. - Read a cell address such as
B2(column B, row 2).
The chapter covers how to point a formula at other cells, what Excel does with the contents of those cells, and what goes wrong when you do this carelessly. Operator precedence, parentheses, copying formulas and error codes each get their own chapter later. They appear here only when an example needs them.
Why a formula should point at cells
Suppose a notebook costs 4.50 and you are buying 10. You could type this in cell D2:
=4.5*10Excel returns 45. The formula is correct, but the numbers 4.5 and 10 now live inside the formula. They are invisible in the sheet, and the only way to change them is to edit the formula itself.
Now put the price in B2 and the quantity in C2, and write this in D2:
=B2*C2The formula contains no numbers. It tells Excel to take whatever is in B2, multiply it by whatever is in C2, and show the result. Excel remembers the relationship, not the answer. If you change C2 from 10 to 12, D2 changes to 54 without you touching the formula.
A number typed into a formula is called a hard-coded value or constant. A cell address used in a formula is called a cell reference. Reference formulas have three practical advantages:
- They stay current. Excel recalculates the result whenever a referenced cell changes.
- They are visible. Inputs sit in cells where you can read, format and label them.
- They scale. The same formula pattern works for every row of a table, which is what makes copying formulas (a later chapter) possible.
A worked example: an order sheet
Build this small table. Row 1 holds headers. Columns B and C hold typed values. Column D will hold formulas.
| Cell range | A (Item) | B (Unit price) | C (Quantity) | D (Line total) |
|---|---|---|---|---|
| Row 2 | Notebook | 4.50 | 10 | formula |
| Row 3 | Pen | 1.25 | 24 | formula |
| Row 4 | Folder | 2.00 | 15 | formula |
Enter these formulas:
=B2*C2=B3*C3=B4*C4The results are 45, 30 and 30. Each formula refers to the price and quantity on its own row.
Next, put a grand total in D5:
=D2+D3+D4This returns 105. This formula refers to cells that themselves contain formulas, and Excel handles that without difficulty. Now change C2 to 12. D2 becomes 54, and D5 becomes 114, because D5 depends on D2. You edited one input, and every cell that depends on it was updated.
How Excel keeps results up to date
Excel tracks which cells depend on which. When you change a cell, it recalculates the formulas that refer to it, then the formulas that refer to those, and so on down the chain. By default this happens automatically, as soon as you press Enter after an edit.
Read the arrows as "is used by". B2 and C2 are the inputs to D2. D2 is an input to D5. This chain of dependencies explains what you see when something looks wrong. A wrong value in D5 may come from D5's own formula, from D2, or from the typed values at the start of the chain.
Two ways to enter a reference
You can type a reference. After the =, type B2, an operator, then C2. Case does not matter, because Excel converts b2 to B2.
You can also point at the cell:
- Select D2 and type
=. - Click cell B2. Excel inserts
B2into the formula and outlines the cell with a colored, moving border. - Type
*. - Click cell C2.
- Press Enter.
Pointing is less error-prone than typing. A mistyped address such as B22 is still valid and silently points at the wrong cell, while a click puts the correct address in. You can also move the selection with the arrow keys while the formula is being written. In that state, an arrow key moves the reference instead of the cell cursor.
If you click a cell at the wrong moment, for example right after a number rather than after an operator, Excel replaces or inserts the address in a way you did not intend. Before pressing Enter, look at the formula in the formula bar and check it reads the way you meant.
Seeing which cells a formula uses
To inspect an existing formula, select its cell and press F2, or double-click the cell. Excel shows the formula in edit mode and draws a colored border around each referenced cell. Each reference in the formula text is drawn in the same color as its border. This is the quickest way to confirm that =B2*C2 is looking at the cells you expect. Press Esc to leave edit mode without changing anything.
To see every formula on the sheet at once, press Ctrl+` (the backtick key, usually above Tab). The cells show their formulas instead of their results. Press the same keys again to switch back. This is also available on the Formulas tab as Show Formulas. Switching it on is a good way to check that a column of results really is formulas and not typed numbers that happen to look right.
What Excel does with the contents of a referenced cell
A reference stands for "the value in that cell". The kind of value matters.
| Cell contents | What `=A1+1` does |
|---|---|
| A number such as 5 | Returns 6 |
| An empty cell | Treats A1 as 0 and returns 1 |
| A date | Uses the date's underlying serial number and adds 1, which gives the next day |
| Text that cannot be read as a number, such as `abc` | Returns the error `#VALUE!` |
| Text that looks like a number, such as `5` stored as text | Arithmetic operators convert it, so the result is 6 |
| An error such as `#DIV/0!` | The error passes through to your formula |
Several of these deserve a closer look.
Empty cells count as zero. If C3 is blank, =B3*C3 returns 0, not an error. This is convenient but can hide a missing input. A line total of 0 might mean "free" or it might mean "nobody entered the quantity yet".
Dates are numbers. Excel stores a date as a count of days. A cell formatted to show 27-Nov-2026 holds a number underneath. That is why =A1+7 on a date gives the date one week later. If you see a five-digit number where you expected a date, the cell needs a date number format. The formula is fine.
Numbers stored as text. Imported data often has numbers that Excel treats as text. Signs include left alignment (numbers align right by default) and a small green triangle in the corner of the cell. Plain arithmetic usually still works on them, as the table shows. Some functions, such as SUM, skip text values and give a smaller total than you expect. If a column of numbers behaves oddly, check whether the entries are text.
Errors travel. If D2 shows an error, then D5, which refers to D2, shows an error too. Fix the cell at the start of the chain, and the later ones clear. A later chapter reads the specific error codes in detail.
Displayed value versus stored value
A formula uses the value a cell stores, not the value it displays. Suppose A1 contains 1.2345 and you format it to show two decimal places. The cell displays 1.23, but =A1*100 returns 123.45, not 123.
This matters when you add up a column of displayed prices and the total on screen differs by a cent from what you worked out by hand. The cells hold more decimal places than they show. Increasing the displayed decimals on the cells reveals the true stored values.
Mixing references and constants
Not every number should become a cell. Some values are fixed by definition, like 12 months in a year or 100 in a percentage calculation. Others are assumptions that may change, like a tax rate, a discount or an exchange rate. The rule of thumb is:
- If the number is a fact that never changes, it can go in the formula.
- If the number is an assumption someone might revise, put it in its own labeled cell and refer to it.
Compare two ways to add 8% tax to a price in B2. The first hides the rate:
=B2*1.08The second keeps the rate in a labeled input cell, F1, holding 8%:
=B2*(1+$F$1)With a price of 4.50, both return 4.86. When the tax rate changes to 9%, the first version means finding and editing every formula that contains 1.08. The second means changing one cell. The $ signs in $F$1 make the reference stay fixed when the formula is copied, and the parentheses force the addition to happen first. Both ideas have their own chapters. For now, notice only that the rate is an input cell rather than part of the formula text.
References to other sheets
A formula can refer to a cell on another worksheet. Put the sheet name, an exclamation mark, then the address:
=Prices!B2*C2Here B2 is read from the sheet named Prices, while C2 is read from the sheet the formula is in. If the sheet name has spaces or punctuation, Excel wraps it in single quotes:
='Price List'!B2*C2The simplest way to build these is to point: type =, click the other sheet's tab, click the cell, and carry on. Excel writes the sheet name for you, including the quotes when they are needed.
Common mistakes
Pointing at the wrong cell. The formula is valid and returns a number, so Excel gives no warning. Use F2 and the colored borders to check which cells are really referenced.
Typing a number over a formula. The cell stops updating. Show Formulas (Ctrl+`) makes this easy to spot across a whole column.
A formula that refers to its own cell. If you enter =D2*2 in cell D2, the formula depends on its own result. Excel calls this a circular reference. It shows a warning and usually displays 0. Check that the address in the formula is not the address of the cell you are typing in.
Mixing up the row. Writing =B2*C3 in D2 multiplies a price by the next row's quantity. Each result looks plausible, so the error is hard to see. Compare each formula with the row it sits on.
Relying on blank cells. A blank input produces 0, not a warning. Keep inputs filled in, or label clearly what a blank means.
Treating a displayed value as exact. If a result seems off by a small amount, check the stored decimals before you suspect the formula.
Exercises
Exercise
In D2 you wrote =4.5*10 for a price of 4.50 and a quantity of 10. Rewrite the formula so that it uses cell references, assuming the price is in B2 and the quantity is in C2. Then say what happens to the result when you change C2 to 12.
Show answer
The formula is =B2C2. With C2 changed to 12, Excel recalculates D2 automatically and shows 54, because 4.50 × 12 = 54. The original =4.510 would still show 45, because its numbers are fixed in the formula.
Exercise
A sheet has B3 = 1.25 and C3 = 24, and C3 is later cleared so that the cell is empty. What does =B3*C3 return, and why might that be a problem?
Show answer
It returns 0, because Excel treats an empty referenced cell as 0 in arithmetic. The problem is that no error appears, so a missing quantity looks the same as a real quantity of zero.
Exercise
You select D5, which should contain =D2+D3+D4, but changing C2 does not change D5. Name two ways to find out why, using the tools from this chapter.
Show answer
Check the formula bar to see whether D5 holds a formula or a typed number, since a typed number never updates. Alternatively, press Ctrl+` to show all formulas, or press F2 on D5 to see its colored reference borders and confirm it points at D2, D3 and D4. Also check that D2 is itself a formula that refers to C2.
Exercise
Why is =B2(1+$F$1), with the tax rate stored in F1, easier to maintain than =B21.08?
Show answer
The rate is stored once, in a labeled cell. If the rate changes, you edit one cell and every formula that refers to it updates. With 1.08 typed into each formula, you must find and edit every formula, and you may miss one.