Sub topic 6
Expanding ranges and running totals
This chapter assumes you can enter and edit a formula, select ranges, and use the fill handle. It also assumes you know what relative, absolute, and mixed references are, and how the dollar sign locks a row or a column. Here you will apply that knowledge to ranges, where one end of the range stays put and the other end moves.
What an expanding range is
A range such as B2:B10 has two ends: a start cell (B2) and an end cell (B10). Each end is a separate reference, and each can have its own dollar signs. When you fill a formula, Excel adjusts each end on its own according to its own reference type.
This means you can anchor one end and leave the other relative. The anchored end stays where it is, and the relative end moves with the formula. The range grows (or shrinks) as the formula is copied. That is an expanding range.
The most common use is a running total, also called a cumulative sum: each row shows the sum of everything from the first row down to the current row.
Building a running total
Suppose column A holds dates, column B holds daily sales, and you want column C to show the total sales so far.
| Row | A (Date) | B (Sales) | C (Running total) |
|---|---|---|---|
| 1 | Date | Sales | Running total |
| 2 | 2026-11-01 | 120 | 120 |
| 3 | 2026-11-02 | 80 | 200 |
| 4 | 2026-11-03 | 150 | 350 |
| 5 | 2026-11-04 | 60 | 410 |
In C2, enter this formula:
C2: =SUM($B$2:B2)The start of the range, $B$2, is absolute. The end, B2, is relative. Now fill the formula down. Excel shifts only the relative end by one row for each row you move:
C2: =SUM($B$2:B2)
C3: =SUM($B$2:B3)Continuing down, C4 contains =SUM($B$2:B4) and C5 contains =SUM($B$2:B5). Every row sums from the fixed starting cell to the current row, which is exactly a running total.
The first formula, =SUM($B$2:B2), sums a range that is a single cell. That is valid, and it makes the formula in the first row identical in structure to all the others. You do not need a special case for the first row.
Why the dollar signs matter here
Compare what happens without the anchor. If you write =SUM(B2:B2) and fill down, both ends are relative, and both move:
C2: =SUM(B2:B2)
C3: =SUM(B3:B3)
C4: =SUM(B4:B4)Each cell now sums only its own row, so you get the daily value repeated and not a running total. This is the most common mistake with expanding ranges, and the result looks plausible for the first row, which makes it easy to miss.
The next diagram shows how the two ends of the range behave as the formula moves down.
Which end do you anchor?
The choice depends on the direction in which the data grows and the direction in which you fill.
- Anchor the start, relative end (
$B$2:B2): the range grows as you fill down. Use this for a running total from the top. - Relative start, anchor the end (
B2:$B$10): the range shrinks as you fill down. Use this for a "remaining" total, such as the sum of everything from the current row to the bottom.
Here is the second form in a formula that shows how much of the list is still to come:
D2: =SUM(B2:$B$10)
D3: =SUM(B3:$B$10)In D2, the range covers B2:B10. In D3, it covers B3:B10. Each row sums itself and everything below it.
You can also use the same idea for columns. If monthly values run across row 2 from B2 to M2, a running total in row 3 would use a column anchor:
B3: =SUM($B2:B2)
C3: =SUM($B2:C2)Here the start $B2 locks the column to B. The end moves right as you fill across. The row part of the start is relative, which is harmless as long as you only fill across. If you also plan to fill down, lock the row as well, as in $B$2:B2.
Running totals that do not include the current row
Sometimes you want the total before the current row, for instance an opening balance for each period. A range that ends one row above the current row would be $B$1:B1 in row 2, which includes the header cell in B1. SUM ignores text, so a text header does not break the sum, but the pattern is fragile. If B1 ever holds a number, the total will be wrong.
A cleaner way is to subtract the current value from the running total:
D2: =C2-B2Here C2 is the running total including the current row, and B2 is the current value, so D2 gives the total before the current row. This keeps the range logic in one column only.
Expanding ranges with other functions
The same pattern works with any function that takes a range. Anchor the start and let the end move.
| Goal | Formula in row 2 | Meaning |
|---|---|---|
| Running average | `=AVERAGE($B$2:B2)` | Average of all values so far |
| Running maximum | `=MAX($B$2:B2)` | Highest value so far |
| Running count of entries | `=COUNT($B$2:B2)` | How many numbers so far |
| Running count of a label | `=COUNTIF($A$2:A2,A2)` | How many times the current label has appeared so far |
The last row of the table uses two ranges with different roles. In =COUNTIF($A$2:A2,A2), the range $A$2:A2 expands, and the criterion A2 is a plain relative reference to the current row's label. Filled down, row 3 becomes =COUNTIF($A$2:A3,A3). This formula is a common way to number repeated items, for example to label the first, second, and third order from the same customer.
Share of total and cumulative percentage
You can combine an expanding range with a fully anchored one. A cumulative percentage divides the running total by the grand total. The grand total must stay fixed for every row, so its whole range is absolute, while the running total uses the expanding range.
C2: =SUM($B$2:B2)/SUM($B$2:$B$10)In this formula, the first SUM expands and the second SUM is locked at both ends. In C2 the result is the first value divided by the grand total. In C10 the result is 1, or 100% when formatted as a percentage. Checking that the last row equals 100% is a useful test that the anchors are correct.
If you only need each row's share of the total, and not the cumulative share, use the pattern from earlier chapters:
C2: =B2/SUM($B$2:$B$10)Here the whole range in SUM is absolute and B2 is relative, so every row is divided by the same total.
What happens when the data changes
An expanding range is only as long as the formulas you have filled. It has a few behaviors worth knowing.
Adding new rows at the end
If you add a new row of data below the last row, the new row has no formula until you fill one in. Copy the last formula down by one row, and the end of the range moves to the new row while the start remains at $B$2.
If your data is in an Excel Table (Insert > Table), Excel often fills the formula into new rows automatically. Table formulas display structured references and not A1 addresses, so the pattern looks different there, and a later chapter on named ranges covers a related approach. For plain ranges, fill manually.
Inserting rows inside the range
If you insert a row in the middle of the data, Excel extends any range that spans the insertion point. For instance, if row 4 is inserted in the middle of $B$2:B6, the formula becomes =SUM($B$2:B7). The sum still covers the whole block. You must still fill the formula into the new row yourself so it has a running total.
Inserting a row directly above the start
If you insert a row above row 2, the anchored start $B$2 moves down to $B$3 and the range does not include the new row. This is expected, because the reference follows the cell it points at. If you want the range to include rows inserted at the top, anchor the start on a header row or a blank row above the data, such as $B$1:B2. This works as long as the cell at the start does not contain a number that would be added to the total.
Deleting the anchor cell
If you delete the row that holds the start cell, the formulas that referred to it show #REF!, because the cell no longer exists. If you expect to delete the first data row, anchor on a header row instead, or restructure the data so the first row is a stable label.
Sorting and running totals
Sorting data that contains a running total can change what the formulas mean. A running total depends on the order of the rows, because each row sums everything above it. After you sort, the values in column B move to new rows and the formulas stay in their rows, so the totals recalculate in the new order. That is correct behavior for a running total, but the totals no longer match the dates if you sort by something other than date. Keep the data sorted in the order in which the running total is meant to be read.
Common mistakes with expanding ranges
| Symptom | Likely cause | Fix |
|---|---|---|
| Each row shows only its own value | Both ends of the range are relative | Add `$` to the start: `$B$2:B2` |
| Every row shows the same total | Both ends are absolute | Remove `$` from the end: `$B$2:B2` |
| Totals shift wrongly when filling across | Anchored the row but not the column, or the reverse | Lock the dimension that must not move |
| The last row is not 100% in a cumulative percentage | The grand total range stops short or is not fully absolute | Use `SUM($B$2:$B$10)` and check the end row |
| `#REF!` after deleting a row | The start cell was deleted | Anchor on a header row or rebuild the formula |
A quick way to debug a running total is to select a cell in the middle of the column and press F2 to enter edit mode. Excel outlines each reference in the formula with a colored border on the sheet. You can see at once whether the start of the range is where you expect and whether the end sits on the current row. Press Esc to leave edit mode without changing anything.
The SUBTOTAL version follows the same anchoring rule:
C2: =SUBTOTAL(109,$B$2:B2)Putting it together
Here is a short plan that applies to any expanding range:
- Decide which end of the range must stay fixed. Usually that is the first row of the data.
- Write the formula in the first row so that the range covers a single cell, for example
=SUM($B$2:B2). - Add dollar signs to the fixed end only. Leave the moving end relative.
- Fill the formula down the whole column.
- Check the first row (one cell), the last row (the whole block), and a middle row (the start fixed, the end on the current row).
Exercise
Column B holds monthly expenses in B2:B13. Write a formula for C2 that, when filled down to C13, shows the running total. Then write a formula for D2 that shows the cumulative percentage of the year's total, and say what value D13 should show.
Show answer
C2: =SUM($B$2:B2). The start is absolute and the end is relative, so the range grows by one row each time the formula is filled down. D2: =SUM($B$2:B2)/SUM($B$2:$B$13), or equivalently =C2/SUM($B$2:$B$13). The denominator is absolute at both ends, so it is the same in every row. D13 should show 1, which is 100% when formatted as a percentage, because the running total in the last row equals the grand total.
Exercise
A colleague fills =SUM(B2:B2) down column C and reports that every row just repeats the value from column B. What is wrong, and what is the corrected formula? Also, which formula would show the sum of the current row and everything below it, down to row 20?
Show answer
Both ends of the range are relative, so both move down together and each formula sums a single row. The corrected formula is =SUM($B$2:B2), which locks the start. For the sum from the current row to row 20, use =SUM(B2:$B$20) and fill down. The end is locked and the start moves, so the range shrinks as you go down.
Exercise
In a list of orders, column A holds customer names in A2:A100. Write a formula for B2 that, when filled down, numbers each customer's orders as 1, 2, 3 and so on in the order they appear.
Show answer
B2: =COUNTIF($A$2:A2,A2). The range starts at the fixed cell A2 and ends at the current row, so it expands. The criterion A2 is the current row's customer name. In each row, COUNTIF counts how many times that name has appeared from the top down to the current row, which gives the order number.