Sub topic 1
How a Formula Points at a Cell
Every Excel formula that uses other cells does so through references. A reference is a small piece of text such as B2 that tells Excel where to find a value. This chapter covers how references are written and what Excel stores behind them. It also covers how to see them on screen. The later chapters build on it, because relative, absolute, and mixed references are all variations on what you learn here.
Prerequisites
This chapter assumes you can already do the following:
- Enter a basic formula by typing
=followed by an expression, and edit it again afterward. - Select a single cell, a block of cells, and a whole row or column with the mouse or keyboard.
- Copy and paste cells, or drag the fill handle (the small square at the bottom-right corner of the selected cell).
You don't need to know any functions beyond SUM.
Cell addresses and A1 notation
A worksheet is a grid. Columns are labeled with letters and rows with numbers. A cell's address is its column letter followed by its row number, with no space. This style is called A1 notation. The cell in column B, row 2 is B2.
After column Z the letters continue as AA, AB, and so on, like a car odometer that uses letters instead of digits. The current Excel grid has 16,384 columns and 1,048,576 rows, so the last cell is XFD1048576.
| Address | Column | Row |
|---|---|---|
| `A1` | A (1st) | 1 |
| `B2` | B (2nd) | 2 |
| `Z10` | Z (26th) | 10 |
| `AA10` | AA (27th) | 10 |
| `XFD1048576` | XFD (16,384th) | 1,048,576 |
Letters and numbers are never mixed in the opposite order. 2B is not an address. Case does not matter, and Excel converts b2 to B2 when you press Enter.
Ranges
A range is a rectangular block of cells. You write it as the top-left address, a colon, and the bottom-right address.
| Reference | Meaning |
|---|---|
| `A1:A10` | Ten cells in column A |
| `A1:C3` | A 3-by-3 block of nine cells |
| `B:B` | The whole of column B |
| `3:3` | The whole of row 3 |
| `A:C` | Columns A, B, and C |
| `2:5` | Rows 2 through 5 |
Two more operators combine references. The comma (the union operator) joins separate areas, and a single space (the intersection operator) gives the cells two ranges have in common.
=SUM(A1:A3, C1:C3)
=SUM(A1:C3 B2:D4)The first formula adds six cells from two separate blocks. The second adds only B2:C3, the overlap of the two ranges. Some regional settings use a semicolon instead of a comma to separate arguments. If a formula from this tutorial is rejected with a comma, try a semicolon.
A reference is a pointer, not a copy
When you write =A2 in another cell, Excel does not copy the value of A2. It stores the instruction "show whatever A2 holds." If A2 changes, the formula's result changes the next time Excel recalculates, which normally happens at once.
Suppose A2 holds a quantity and B2 holds a price. This formula in C2 multiplies them:
C2: =A2*B2If you change A2 from 4 to 5, C2 updates without any action from you. The formula stores where its inputs are, not what they were when you typed it. The cells a formula reads from are called its precedents. The cells that read from a given cell are its dependents. In this example A2 and B2 are precedents of C2, and C2 is a dependent of both.
Arrows in this diagram point from the cell being read to the cell doing the reading. Excel keeps a dependency graph like this behind the scenes. When a precedent changes, Excel recalculates only the dependents, directly and indirectly, rather than the whole workbook.
What the formula actually stores
Here is the fact that explains the rest of this tutorial. When you type =A2*B2 in C2, Excel does not store "column A, row 2." By default it stores "the cell two columns to the left, in the same row," and "the cell one column to the left, in the same row." It records each reference as a distance from the formula's own cell.
Excel can show this form if you switch to R1C1 notation. In R1C1, R stands for row, C stands for column, and a number in square brackets is an offset from the current cell. A negative offset points up or left, and a positive offset points down or right. No brackets means "the same row" or "the same column." You can switch under File > Options > Formulas by ticking "R1C1 reference style." In that style, the formula in C2 appears like this:
=RC[-2]*RC[-1]It reads as "same row, 2 columns left" times "same row, 1 column left."
Now look at the formula in the row below, C3:
C2: =A2*B2
C3: =A3*B3In A1 notation these two formulas differ. In R1C1 notation they are identical: =RC[-2]*RC[-1] in both cells. Excel considers them the same formula, and they just sit in different places. This is why filling down works. The fill handle copies the stored offsets, and Excel redisplays them as addresses relative to the new location.
This default behavior is called relative referencing, and the next chapter covers it in detail. You can opt out of it for a specific reference by putting dollar signs in front of the column letter, the row number, or both. Excel then stores a fixed position in place of an offset. For comparison, $A$1 looks like this in R1C1:
=R1C1It has no brackets because it names row 1, column 1 directly. Keep this one idea in mind: a reference is either "this many steps from me" or "this exact cell." A1 notation writes both kinds, and the dollar sign is the only visible difference.
Seeing the pointers
Reading a formula's text is not always the quickest way to understand it. Excel offers several ways to see references directly.
- Edit mode highlighting. Select a formula cell and press
F2. Each reference in the formula text is colored, and the matching cell or range on the sheet gets a border in the same color. You can drag the colored border to retarget the reference, or drag its corner handle to resize a range. - Show Formulas. Press
Ctrl+ ``(the backtick key, usually aboveTab`) to display formula text instead of results in every cell. Press it again to switch back. This is the fastest way to scan a whole block for a formula that differs from its neighbors. - Trace Precedents and Trace Dependents. On the Formulas tab, in the Formula Auditing group, these draw blue arrows to the cells a formula reads from, or to the cells that read from the selected one. Remove Arrows clears them.
- Evaluate Formula. In the same group, this steps through a formula one calculation at a time and shows each reference being replaced by its value.
Building references by pointing
You don't have to type addresses. After typing =, click a cell and Excel inserts its address. Drag across cells and it inserts a range. Pointing avoids typos, and for references to other sheets it also handles the quoting for you.
Pointing works only while Excel is in a mode that accepts references. That is the case right after you type =, an operator such as + or *, an opening parenthesis, or a comma. If you click a cell at a moment when a reference does not fit, Excel finishes the formula and moves the selection instead. Typing =A2 and then clicking B2 ends the entry rather than adding B2. Type the operator first.
Other places a reference can point
Other sheets and workbooks
A reference to another worksheet starts with the sheet name and an exclamation mark.
=Rates!B1
='Q1 Sales'!B2Sheet names that contain spaces or punctuation must be wrapped in single quotes. Excel adds the quotes when you point and click. If you type the reference yourself and leave them out, you will get an error. The chapter on cross-sheet references returns to this.
A reference to another workbook adds the file name in square brackets, such as =[Budget.xlsx]Sheet1!B2. When the other file is closed, Excel shows the full file path in the formula. These links break if the file is moved or renamed.
Defined names
A defined name is a label you attach to a cell or range, so that a formula can say TaxRate in place of E1. Under the hood it is still a reference. A later chapter compares names with dollar signs. For now, note that a name cannot look like an address. TAX1 is rejected, because column TAX exists (letters up to XFD are valid column labels) and row 1 exists. TaxRate is fine. The single letters R and C are also not allowed as names, because R1C1 notation uses them.
Text that merely looks like a reference
Quotation marks turn a reference into plain text.
=A1
="A1"The first formula returns whatever is in A1. The second returns the two characters A1. If you need to build a reference from text, the INDIRECT function converts a string into a live reference, as in =INDIRECT("A"&ROW()). It is flexible, but Excel cannot trace it and it recalculates on every change. Treat it as a last resort.
What a reference returns
A reference returns the value of the target cell, with a few behaviors that surprise people.
- An empty cell counts as 0 in arithmetic.
=A5+1returns 1 ifA5is blank. If you point directly at a blank cell with=A5, the result displays as 0, not as blank. - Text in arithmetic causes
#VALUE!.=A2*B2fails if either cell holds text such as "N/A" or a number stored as text. A number stored as text usually has a small green triangle in the corner of the cell and is left-aligned. - A reference to a deleted cell becomes
#REF!. If you delete the row or column a formula points at, Excel has nothing to point to and rewrites the reference as#REF!, for example=#REF!*B2. Undo the deletion straight away if you can, because the original address is not recoverable from the formula once the file is saved. - A cell cannot refer to itself. A formula in
A1that reads=A1+1is a circular reference. Excel warns about it and stops calculating the result. The status bar shows the address of a cell involved in the loop.
Common mistakes at this stage
| Symptom | Likely cause | Fix |
|---|---|---|
| Formula shows as text, such as `=A2*B2` in the cell | Cell is formatted as Text, or the formula began with an apostrophe or space | Set the format to General, then re-enter the formula |
| Result is 0 for a cell that looks full | The referenced cell is a different one than intended, or holds a blank-looking space | Press `F2` and check the colored border, or use Trace Precedents |
| `#NAME?` after typing a sheet reference | Sheet name with a space is missing single quotes | Wrap the name in `'...'` or point and click |
| Click on a cell moves the selection and does not add a reference | Excel was not in a state that accepts a reference | Type the operator, comma, or parenthesis first |
| Two neighboring formulas give inconsistent results | One was edited by hand, so its offsets differ | Compare the cells in R1C1 style, or press `Ctrl` + `` ` `` |
Where this leads
Every behavior in the rest of this tutorial comes from the fact that a reference is stored either as an offset or as a fixed position. The next chapter works through the first kind. It shows what happens to those offsets when you copy and fill a formula. The chapters after it show how to lock part or all of a reference when you don't want it to move.
Exercise
A formula in cell D5 reads =B5+C5. Without using R1C1 style, say which cells it refers to relative to D5, and how Excel would store those two references in R1C1 notation.
Show answer
It refers to the cell two columns to the left (B5) and the cell one column to the left (C5), both in the same row. In R1C1 notation the formula is =RC[-2]+RC[-1].
Exercise
What does =SUM(A1:C3 B2:D4) add up, and why?
Show answer
It adds the cells in B2:C3. The space between the two ranges is the intersection operator, so the formula uses only the cells the ranges share.
Exercise
You type =A2 in a cell, and later you change the value in A2. Does the formula cell keep its old result? Explain what the formula stores.
Show answer
No. The formula stores a pointer to A2, not a copy of its value, so when A2 changes Excel recalculates the formula and shows the new value (unless calculation is set to manual).
Exercise
Why can't you create a defined name called TAX1, and what could you use in its place?
Show answer
TAX1 is a valid cell address, since TAX is a column label and 1 is a row number. Excel does not allow names that look like addresses. A name such as TaxRate or Tax_1 works.