A normal SUM adds every row — even the ones a filter has hidden. SUBTOTAL adds only the visible rows, so your total updates to match whatever the AutoFilter is showing.
109 means SUM-ignoring-hidden-rows; SUBTOTAL recalculates as you filter.
The example
A filter is showing only West rows; the total reflects just those.
| A | B | |
|---|---|---|
| 1 | Region | Amount |
| 2 | West | $120 |
| 3 | East (hidden) | $90 |
| 4 | West | $200 |
| 5 | Visible total: | $320 |
The formula
The filtered total:
How it works
The function number controls both the operation and the hidden-row behavior:
- The first argument is a function code:
9= SUM,1= AVERAGE,2= COUNT,4= MAX, and so on. - Codes in the 100s (
109,101…) also ignore rows hidden manually, not just by filter. Codes in the 1–11 range ignore filtered rows but keep manually hidden ones. - As you filter, SUBTOTAL recalculates to total only what’s on screen —
320for the two West rows. - Bonus: SUBTOTAL ignores other SUBTOTALs in the range, so nested subtotals don’t double-count.
AGGREGATE goes further. =AGGREGATE(9, 5, B2:B100) sums visible rows and can ignore errors (option 6) — handy when the column has stray #N/As.
Try it: interactive demo
Toggle which rows are “filtered out”; compare SUM vs SUBTOTAL.
Variations
Average / count visible rows
Change the function code:
Visible rows AND ignore errors
AGGREGATE option 5 = ignore hidden; 6 = ignore errors (use 7 for both):
A live row counter
Number only visible rows:
Pitfalls & errors
9 vs 109. Code 9 ignores filtered rows but still counts rows you hid by right-clicking → Hide. Code 109 ignores both. Pick deliberately.
SUBTOTAL only reacts to row hiding, not to hidden columns or to IF conditions. For conditional totals, use SUMIFS.
Don’t mix data and a SUBTOTAL in the same range by accident — though SUBTOTAL conveniently skips other SUBTOTALs, a stray total cell inside the range can still confuse a reader.
Practice workbook
Frequently asked questions
How do I sum only visible rows after filtering in Excel?
What's the difference between SUBTOTAL 9 and 109?
How do I sum visible rows and ignore errors too?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class