The SUBTOTAL formula in Excel lets you sum visible rows in a filtered list without including hidden data — perfect for dynamic reports. Unlike SUM, it ignores rows hidden by filters or manual row hiding, making it ideal for dynamic data analysis. You don’t need anything special to use it — just a table of numeric data and the ability to apply filters.
What You'll Need
- A Microsoft Excel workbook (2010 or later)
- A range of data with column headers
- Access to the Data tab to enable filtering
Step-by-Step
- Organize your data in a table format with clear column headers — for example, columns for Product, Sales, Region, and Date. Ensure there are no blank rows within your dataset.
- Select any cell within your data range, then go to the Data tab on the ribbon and click Filter. This adds dropdown arrows to each column header.
- Click the dropdown arrow in any column (e.g., Region) and apply a filter — for example, select only "North" to hide all other regions.
- Click on the cell where you want the subtotal to appear — typically just below your data or in a summary row.
- Type the formula:
=SUBTOTAL(9, range). Replace "range" with the actual range of cells you want summed — for example,=SUBTOTAL(9, D2:D100)if your sales data is in column D from row 2 to 100. - Press Enter. Excel calculates the sum of only the visible rows, ignoring any rows hidden by the filter.
- Test the formula: change the filter settings (e.g., select "South" instead of "North") and confirm the subtotal updates automatically.
Common Mistakes
- Using SUM instead of SUBTOTAL — SUM includes hidden rows and defeats the purpose of dynamic filtering.
- Using the wrong function number — SUBTOTAL accepts numbers 1-11 or 101-111. For summing visible cells, you must use 9 (or 109 if you want to ignore manually hidden rows too).
- Including entire columns — for example,
=SUBTOTAL(9, D:D)may slow down Excel and cause errors if there’s text or empty cells above or below your data range. - Applying the formula to a filtered list without enabling AutoFilter first — the formula won’t respond to hidden rows if filters aren’t active.
- Typing the function name incorrectly — SUBTOTAL is one word, all uppercase, with no spaces.
Tips
- Use 109 instead of 9 if you want the formula to ignore rows hidden by manual row hiding (right-click > Hide), not just filter hiding. Use 9 only if you want to include manually hidden rows in the calculation (they’ll still be excluded if filtered).
- Combine SUBTOTAL with structured references if your data is in an Excel Table (Insert > Table). For example,
=SUBTOTAL(9, Table1[Sales])automatically expands when new rows are added. - For multiple subtotals, copy the formula to other columns — for example, copy your sum formula to calculate subtotals for Quantity or Revenue in adjacent columns.
- Use the Subtotal feature (Data > Subtotal) if you want to automatically insert multiple subtotal rows by group — but note this creates static rows, while SUBTOTAL is dynamic.
- Press Ctrl + Shift + \\ to quickly toggle visibility of hidden rows and see how your subtotal changes in real time.
Troubleshooting
If your SUBTOTAL formula isn’t updating or shows an error:
- Check for #VALUE! — this means the function number is invalid. Use only 9 or 109 for summing visible cells. Numbers like 12 or 88 will cause errors.
- If the result is zero despite visible data, verify the data range doesn’t include text, blank cells, or errors. SUBTOTAL ignores non-numeric values but treats them as zeros if they’re within the range.
- If the formula doesn’t respond to filtering, ensure AutoFilter is enabled. Select your data range, go to Data > Filter, and confirm dropdown arrows appear.
- If you’re using Excel Online or a mobile app, some versions don’t support dynamic SUBTOTAL updates. Use the desktop version for full functionality.
- If you copied the formula from another cell and it references the wrong range, double-check cell references — use F2 to edit and verify the range matches your data.
- Recalculate manually: press F9 to force Excel to recalculate all formulas. Sometimes calculation mode is set to Manual (Formulas > Calculation Options).
Frequently Asked Questions
Can I use SUBTOTAL with other functions like average or count?
Yes. SUBTOTAL supports 11 functions. Use 1 for AVERAGE, 2 for COUNT, 3 for COUNTA, 4 for MAX, 5 for MIN, 6 for PRODUCT, 7 for STDEV, 8 for STDEVP, 9 for SUM, 10 for VAR, and 11 for VARP. Use 101-111 to ignore manually hidden rows too.
Why does my subtotal show a different number than SUM?
SUBTOTAL ignores hidden rows; SUM includes them. If you’ve filtered your data, the difference means hidden rows contain values. Check your filter settings to see which rows are excluded.
Does SUBTOTAL work with pivot tables?
No. Pivot tables have their own summary options. Use the built-in Sum, Average, or Count functions within the pivot table field settings instead.
What if I have merged cells in my data range?
Subtotal may not calculate correctly if merged cells exist in the range. Always unmerge cells before applying filters or formulas. Use Data > Text to Columns or manually split merged cells.
Can I use SUBTOTAL across multiple sheets?
No. SUBTOTAL only works within one range on the same sheet. For cross-sheet sums, use SUM with 3D references (e.g., ='Sheet1:Sheet3'!D2:D100), but this won’t ignore hidden rows.
Is SUBTOTAL compatible with Excel for Mac?
Yes. The formula works identically on Mac and Windows versions of Excel 2010 and later. Ensure filters are enabled and the range is properly defined.