SUBTOTAL(9, range) adds up the numbers in a range exactly like SUM does — with one crucial difference: it ignores any rows that are hidden by a filter. The 9 is the function number for SUM inside the SUBTOTAL wrapper. That single quirk is why it exists, and it's the reason so many spreadsheets break when people filter a list and their totals stop matching what's on screen. In practice you write it as =SUBTOTAL(9,B2:B200), filter your table with AutoFilter, and the result instantly recalculates to the visible rows only.
So a formula like =SUBTOTAL(9,D2:D500) in a filtered sales table will show the sum of only the rows currently displayed. Clear the filter and it returns to the full total. Nothing else about it changes: nested SUBTOTALs are ignored so the grand total never double-counts, and error values in hidden rows are also skipped. Menu labels can differ slightly by version and platform, but the function itself works the same in desktop Excel everywhere.
What You'll Need
- Excel on desktop (Microsoft 365, Excel 2021, 2019 or later) — or Excel for the web. The function exists in Excel for Mac too.
- A table or list with a header row, one column of numbers you want to total, and no blank rows breaking the data into chunks.
- AutoFilter switched on for that list, otherwise the hidden-rows behaviour never kicks in and SUBTOTAL behaves identically to SUM.
Step-by-Step
- Check your data is clean. Each column should have one data type. Numbers stored as text (often left-aligned with a green triangle in the corner) will be ignored by SUBTOTAL just as they are by SUM, so the figure will look wrong. Convert them with Data > Text to Columns or multiply the range by 1 in an empty helper cell and paste back as values.
- Turn on filtering. Click any cell inside your list and go to Data > Filter. Drop-down arrows appear in the header row. If you're using a formatted Excel Table (Insert > Table), filtering is already available on the header row.
- Pick an empty cell below or beside the data where the total should appear — typically just under the last number in the column, outside the filtered list so the total doesn't get hidden itself.
- Type the formula. Start with
=SUBTOTAL(9,, then select the numeric range. Include the header cell only if you want TEXT values ignored anyway — safer to start at the first data row:=SUBTOTAL(9,D2:D500). Press Enter. - Confirm it is the right function number. 9 means SUM. If you also need averages, counts or maximums in the same report, use 1 for AVERAGE, 2 for COUNT (numbers only), 3 for COUNTA (non-blank), 4 for MAX, 5 for MIN, 6 for PRODUCT, 7 for standard deviation, 8 for population standard deviation, and 9 for SUM. The 101–109 series does the same jobs but ignores manually hidden rows as well as filtered ones.
- Filter a column and watch the total change. Choose a category in one of the drop-downs. The SUBTOTAL cell should recalculate to the visible rows. Compare it against the full unfiltered number to sanity-check the logic.
- Repeat the formula down the sheet if you have several blocks — for example a subtotal per region and a grand total at the bottom. Because SUBTOTAL ignores other SUBTOTAL results, a grand total written as
=SUBTOTAL(9,D2:D500)that covers the smaller subtotals will not double-count them, provided none of them sit inside a filtered-out row group at the same time as their detail rows.
Common Mistakes
Using plain SUM and wondering why filtered totals don't change. SUM adds every cell in the range, visible or not. That's the number one reason a filtered report looks overstated. Swap to SUBTOTAL(9, …).
Forgetting the second argument. =SUBTOTAL(9) or =SUBTOTAL(D2:D500) returns an error. The function number and the range are both required, separated by a comma.
Mixing the 1–11 and 101–111 series. If somebody manually hides a row (right-click > Hide) rather than filtering it, plain SUBTOTAL still counts it. Use 109 if manually hidden rows must be excluded too — and be aware that switching series changes results for anyone reviewing the file, so label it.
Placing the total inside the filtered range. If the formula cell sits within the range being filtered, it can vanish or end up summing itself in a circular reference. Keep totals outside the data block.
Copying a SUBTOTAL row into a filtered list and then filtering again. The subtotal row may be hidden or the result may shift unpredictably. Keep summary rows clearly separated.
Expecting SUBTOTAL to fix text numbers or error cells. It ignores errors and text, so a broken cell stays silently excluded from the total. Check that your visible row count matches the number of values being summed.
Tips
- Use
SUBTOTAL(3, range)next to the sum as a visible-row counter, so you can quickly see how many records are actually being added. - Pair it with
SUBTOTAL(1, range)for a filtered average — invaluable when the mean of visible jobs differs sharply from the mean of all jobs. - Format the range as an Excel Table (Ctrl+T) so the formula expands automatically as new rows are added; filter arrows come for free.
- Remember that SUBTOTAL does not work on rows hidden by a pivot table's own filters in the same way — pivot tables have their own totals, and putting SUBTOTAL outside a pivot range counts the pivot's output cells, not the source rows.
- Use
AGGREGATEif you also need to ignore error values as well as hidden rows; it takes a different set of function numbers, so read the tooltip carefully. - On Excel for the web and Mac, the same function numbers apply, but dialog wording and ribbon positions can differ. If you can't find a command, type the formula instead of hunting for it.
Troubleshooting
The total doesn't change when I filter. Check you actually applied Data > Filter, not merely formatted the range. Then confirm the formula references the same column and rows as the filter. If the total sits above the filter and uses a fixed range, make sure no rows in between are excluded by the range itself.
The result is zero or lower than expected. Numbers are probably stored as text. Select the column, look at the alignment; numbers right-align by default. Use Data > Text to Columns > Finish, or paste-special multiply to force conversion.
You see #VALUE!. Either the function number is missing or malformed, or the range contains a comma-separated mix of numbers and text referenced directly rather than as a range. Rewrite as =SUBTOTAL(9,D2:D500).
The total includes rows you manually hid. Switch to the 100-series: =SUBTOTAL(109,D2:D500).
The grand total double-counts a subtotal. If the smaller subtotals are themselves in the summed range but are not SUBTOTAL formulas, they get added twice. Make every intermediate total a SUBTOTAL formula so the outer one skips them.
It worked yesterday and now shows a different number. Check for a changed filter, a deleted row, or a formula copied with relative references that shifted. Press Ctrl+` (Ctrl+grave) to reveal all formulas and inspect the references.
Frequently Asked Questions
What does the 9 mean in SUBTOTAL?
It is the function number for SUM. SUBTOTAL has no dedicated sum version; you pass a number that tells it which operation to perform, and 9 selects addition.
What is the difference between 9 and 109?
9 ignores rows hidden by a filter but still counts rows you hid manually. 109 ignores both filtered-out and manually hidden rows.
Does SUBTOTAL work without a filter?
Yes — it behaves like SUM and totals everything in the range. You only get the filtered behaviour once rows are hidden.
Can I use SUBTOTAL on multiple columns?
Yes. Select several adjacent columns, such as =SUBTOTAL(9,D2:F500), and you get a column-by-column total for each. Grabbing the fill handle across copies the formula correctly.
Why does SUBTOTAL ignore some rows even when nothing is filtered?
Because it skips other SUBTOTAL results and ignores text and error values. A value missing from the total is usually text, an error, or a nested subtotal.
Is SUBTOTAL available on Excel for Mac and the web?
Yes, the function and its numbering work the same. Ribbon and menu wording can differ slightly, so typing the formula is the most reliable route.