How to Create a SUBTOTAL in Excel

If you just need to create a subtotal in excel and move on, the boxed answer at the top is all you need. The rest of this page is for when you want to understand why it works in Excel, adapt it to a trickier version, or make it robust enough to hand to a colleague. We keep the opening short on purpose — the depth is here when you want it, not in your way when you don’t.

Exact answer

In Excel: use =SUBTOTAL(9, range) — it sums only the visible rows, so a filtered table's total updates as you filter instead of staying stuck on the full set.

Syntax

=SUBTOTAL(function_num, ref1, ...)

Arguments

ArgumentDescription
function_numrequiredWhich calculation to run: 9 sums, 1 averages, 3 counts. Add 100 (109, 101, 103) to also ignore manually hidden rows.
ref1requiredThe range to aggregate. Further ranges can follow.

Related functions

AGGREGATESUMIFCOUNTIF
Annotated stepsExcel
1

Click a cell above or below the data — not inside the filtered range itself.

2

Type =SUBTOTAL( and then the function number: 9 for a sum.

3

Add a comma and select the data range.

4

Press Enter, then apply a filter and watch the total change to match what is on screen.

Ctrl+CthenCtrl+Shift+V+Cthen+Ctrl+VPaste values · WindowsMac

Need it as an auditable file?

Ships inside the linked template — formula-driven, unlocked, audit-ready.

View template

What this does

SUBTOTAL runs one of eleven aggregations, chosen by a number, and — crucially — ignores rows hidden by a filter. That is what makes a filtered table's total honest: a plain SUM keeps totalling rows the filter has removed from view. The function number chooses the operation (9 = SUM, 1 = AVERAGE, 2 = COUNT, 3 = COUNTA, 4 = MAX, 5 = MIN). Adding 100 to it (109, 101 and so on) additionally excludes rows you hid by hand, not just filtered ones. SUBTOTAL also ignores any nested SUBTOTAL inside its own range, so section totals do not get double-counted in a grand total. Keep the inputs visible and clearly labelled and the whole thing stays auditable — anyone who opens the file later, including you, can see at a glance exactly what feeds the result and change one assumption without hunting through the formula. Treat “create a subtotal in excel” as a small repeatable workflow rather than a one-off click you hope to remember next time. Use a small test block before the live file, so any surprise in the affected cells shows up while it is still harmless. When a formula is involved, keep the inputs labelled beside it, reference cells instead of typing values, and apply number formatting only after the result checks out. That turns a calculation you can defend to a CFO or an auditor into a method you can reuse, explain, and defend when the workbook leaves your screen.

A worked example

Above a filtered sales table, =SUBTOTAL(9, D2:D500) shows the total of just the rows currently visible and recalculates on every filter change. To average only visible rows, =SUBTOTAL(1, D2:D500). To exclude manually hidden rows as well as filtered ones, =SUBTOTAL(109, D2:D500). SUBTOTAL is what makes a filtered report tell the truth, because it totals what the reader can actually see. If there is any chance you will reuse this, drop it into a small template tab right now: a labelled input area on the left and the formula beside it, checked once against the tool above. Next time the same question comes up, the answer is a single paste away instead of a rebuild from memory.

In Google Sheets

Google Sheets handles this almost identically to Excel. The formula syntax above is the same, and the menu lives under a slightly different label rather than a ribbon tab. Use the platform toggle at the top of the page to switch every keyboard shortcut between Windows and Mac, and expect at most cosmetic differences in naming. The aim was to get you unstuck fast and leave you a little more capable than a copy-paste would. The answer is at the top, the tool proves it, and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. The short version of “create a subtotal in excel”: the answer is at the top of this page, the tool proves it on your own numbers, and the sections above explain why it holds so the next variation does not stump you. Excel rewards people who reference cells instead of typing values and who keep inputs separate from formulas, because that is what makes a result you can audit months later. Build it once, deliberately, with the live tool as a check, and you convert a one-off lookup into a reusable skill — which is the whole point of learning the why and not just the what.

Common mistakes

  • Using 9 when rows were hidden by hand rather than filtered — 9 still counts those. Use 109 to exclude both kinds.
  • Placing the SUBTOTAL cell inside the filtered range, where the filter can hide the total itself.
  • Reaching for SUBTOTAL when the requirement is a condition rather than a filter; SUMIFS is the right tool for "sum where region = West".

Frequently asked questions

What is the difference between SUBTOTAL and SUM?

SUM totals every row in the range regardless of filtering. SUBTOTAL(9, …) totals only the rows a filter is currently showing.

What do the function numbers mean?

1 AVERAGE, 2 COUNT, 3 COUNTA, 4 MAX, 5 MIN, 6 PRODUCT, 7 STDEV, 8 STDEVP, 9 SUM, 10 VAR, 11 VARP. Add 100 to any of them to also ignore manually hidden rows.

Does SUBTOTAL double-count nested subtotals?

No. It deliberately ignores other SUBTOTAL results inside its range, so a grand total over sections stays correct.