How-to recipes · Counting and summing
How to calculate a running total in Excel
Build a cumulative sum that grows row by row with SUM and a mixed reference, SCAN in Microsoft 365, or a running total per group with SUMIF.
A running total, also called a cumulative sum, shows how a figure builds up over time: sales year-to-date after each month, the balance of an account after each transaction, the number of units produced so far this week. Each row shows the sum of everything from the first row down to the current one. It is easy to build, but there are a few traps, especially when rows are inserted, sorted, or when the data lives in an Excel table.
The example data
Monthly sales for the first half of the year in A1:B7. The running total in column C should end with the half-year total in C7.
Every version: SUM with an expanding range
In C2 type the formula below and copy it down to C7:
| A | B | C | |
|---|---|---|---|
| 1 | Month | Sales | Running |
| 2 | Jan | 4200 | |
| 3 | Feb | 3900 | |
| 4 | Mar | 4600 | 12700 |
| 5 | Apr | 5100 | |
| 6 | May | 3800 | |
| 7 | Jun | 4700 |
This is the formula as it appears in C4 after copying: January to March, 4200 + 3900 + 4600.
Result: 12700
The trick is the mixed reference $B$2:B2 in the first row. The start $B$2 is locked with dollar signs, so it never moves. The end B2 is relative, so when you copy the formula one row down it becomes B3, then B4, and the range grows by one row each time. Cell references: relative, absolute and mixed explains absolute and relative references in detail.
The "previous plus current" version
Another common formula is =B2 in C2 and =C2+B3 in C3, copied down. It is slightly faster on huge sheets because each row adds just two numbers. The drawback: if you delete a row, every formula below it shows #REF!, and if C1 holds a header, writing =C1+B2 in C2 gives #VALUE!. The SUM version is more robust.
Microsoft 365: one formula with SCAN
SCAN walks through an array and keeps an accumulator, returning every intermediate value. With LAMBDA it produces the whole running total from one cell:
| A | B | C | |
|---|---|---|---|
| 1 | Month | Sales | |
| 2 | Jan | 4200 | 4200 |
| 3 | Feb | 3900 | 8100 |
| 4 | Mar | 4600 | 12700 |
| 5 | Apr | 5100 | 17800 |
| 6 | May | 3800 | 21600 |
| 7 | Jun | 4700 | 26300 |
SCAN starts at 0, adds each month's sales, and spills all six intermediate totals.
total is the running value and x is the current cell. Because it is a single formula, you cannot accidentally overwrite or forget to copy one row. When B2:B7 is a table column or grows, point SCAN at the whole column of the table.
A running total per group
When the list contains several people or products mixed together, you usually want each one's own running total. Use SUMIF with two expanding ranges:
| A | B | C | |
|---|---|---|---|
| 1 | Rep | Sales | Rep total |
| 2 | Ana | 300 | |
| 3 | Ben | 250 | |
| 4 | Ana | 150 | |
| 5 | Ben | 400 | 650 |
| 6 | Ana | 200 |
In row 5, Ben's sales so far are 250 + 400. Copy the formula from C2 down to C6.
Result: 650
Each row adds only the earlier rows that have the same rep. The data does not need to be sorted, but if it is sorted by date, the result reads as each person's year-to-date figure.
Running totals inside an Excel table
Tables use structured references, and =SUM([@Sales]) refers only to the current row. To get an expanding range in a table, use INDEX to build the start of the range: =SUM(INDEX([Sales],1):[@Sales]). INDEX returns a reference to the first cell of the column, and the colon creates a range from there to the current row. Unlike $B$2:B2, this survives sorting and adding rows.
Pitfalls
- Sorting. Running totals depend on row order. Sort by date before reading them, and remember that re-sorting by another column produces meaningless cumulative numbers.
- Inserting rows at the top. Inserting a row above row 2 changes
$B$2into$B$3in the existing formulas, and the new row is not included. Insert new data inside the range or use a table. - Filtering. SUM includes hidden rows. For a running total of only the visible rows, use
=SUBTOTAL(109,$B$2:B2); see How to sum only visible cells in Excel. - Text in the Sales column. A value like
n/ais ignored by SUM but breaks theC2+B3version with#VALUE!.