Sub topic 1
Cells and ranges: what the functions read
SUM, AVERAGE, MIN, MAX, and COUNT do not look at a worksheet as a whole. Each one reads only the cells you point it at. This chapter covers how you point at cells, so the later chapters can focus on what each function does with them.
Prerequisites
This chapter assumes you can:
- Enter and edit values in worksheet cells.
- Select cells and ranges with the mouse or keyboard.
- Start a formula with an equals sign (
=).
Cell references
Every cell has an address made of its column letter and row number. The cell in column B, row 3 is B3. This style is called A1 notation. A formula that contains B3 reads whatever is in that cell at the moment Excel calculates, so the result updates when the value changes.
Ranges
A range is a rectangular block of cells. You write it as the top-left cell, a colon, and the bottom-right cell. The colon means "everything from here to there."
| Range | What it covers |
|---|---|
| `B2:B6` | Five cells in one column |
| `B2:D2` | Three cells in one row |
| `B2:D6` | A block of 15 cells, three columns by five rows |
| `B:B` | The entire column B |
| `2:2` | The entire row 2 |
Consider this small sheet:
| Row | A | B | C |
|---|---|---|---|
| 1 | Region | Sales | Returns |
| 2 | East | 120 | 10 |
| 3 | West | 95 | 5 |
| 4 | East | 140 | 12 |
| 5 | North | 80 | 0 |
| 6 | West | 110 | 8 |
Here are some references into it:
=SUM(B2:B6)
=SUM(B2:C6)
=SUM(B:B)The first formula reads five cells and returns 545. The second reads a 5-by-2 block and returns 545 plus 35, which is 580. The third reads all of column B. The header "Sales" is text, and SUM skips text, so it also returns 545.
Selecting a range while you type
You do not have to type addresses. After typing =SUM(, drag across the cells with the mouse or hold Shift and press the arrow keys. Excel writes the address for you and colors the matching cells on the sheet. The colored outlines show exactly which cells the formula will read. Check them before pressing Enter.
Ranges are live
A range is a pointer, not a copy of the values. Three behaviors follow from this:
- Changing a value inside the range changes the result.
- Inserting a row in the middle of
B2:B6stretches the range toB2:B7. - Inserting a row after the last row, such as below row 6, does not stretch it. The new row is outside the range.
Common range mistakes
Most wrong totals come from the range, not the function:
- Off-by-one ranges.
B2:B5silently leaves out row 6. The formula still works, so Excel shows no error. - Including the total cell. If the total sits in
B7and the formula is=SUM(B2:B7), the formula reads its own cell. Excel reports a circular reference. - Including the header. This is usually harmless for SUM, because text is skipped. It can change what COUNTA returns, so keep headers out of the range.
- Mixing up direction.
B2:D2reads across a row.B2:B4reads down a column. Check the orientation against the data.
Exercise
A sheet has headers in row 1 and numbers in B2:B20. You put the total in B21 and write =SUM(B1:B21). What happens, and how do you fix it?
Show answer
B21 is inside the range, so the formula reads its own cell. Excel reports a circular reference. Change the formula to =SUM(B2:B20), which leaves out the header and the total cell.