If your SUBTOTAL function in Excel isn't returning the expected result, it's usually because the data isn't properly structured for aggregation, hidden rows aren't being respected, or the function is misapplied. SUBTOTAL ignores hidden rows and only works on filtered or manually hidden data—so if you're seeing the same result as SUM, you've likely forgotten to filter or have formatting issues. The fix requires checking your data layout, function syntax, and cell references. Here's how to make it work correctly.

What You'll Need

  • A Microsoft Excel workbook (2010 or later recommended)
  • A column of numeric data to aggregate
  • At least one filter applied or manually hidden rows
  • Access to the Formula bar and Function Arguments dialog

Step-by-Step

  1. Ensure your data is in a structured table or contiguous range with headers. SUBTOTAL works best when applied to a single column of numbers with no text or blank cells in between. If your data has gaps, insert zeros or remove blank rows.
  2. Click the cell where you want the subtotal result to appear, typically below or beside your data range.
  3. Type =SUBTOTAL( and press Ctrl+A to open the Function Arguments dialog, or type the full syntax manually: =SUBTOTAL(function_num, ref1, [ref2], ...).
  4. Choose the correct function number from the table below:
    • 9 or 109 for SUM (109 ignores manually hidden rows; 9 ignores only filtered rows)
    • 1 or 101 for AVERAGE
    • 2 or 102 for COUNT
    • 3 or 103 for COUNTA
    • 4 or 104 for MAX
    • 5 or 105 for MIN

    Use 100-series numbers (like 109) if you want to ignore both filtered AND manually hidden rows. Use 90-series (like 9) if you only want to ignore filtered rows but still count manually hidden ones.

  5. Select the range of cells you want to subtotal—do not include the cell where the SUBTOTAL formula is located. For example, if your data is in cells B2:B100, select that range. Avoid selecting entire columns (like B:B) as this can cause performance issues and incorrect results.
  6. Press Enter to confirm. The result should now update dynamically when you apply or remove filters.
  7. Apply a filter: Select your data range, go to the Data tab, and click Filter. A dropdown arrow will appear on each column header.
  8. Use the dropdown to hide certain values (e.g., filter out "Pending" or "Cancelled" entries). The SUBTOTAL result should now change to reflect only visible rows.
  9. Manually hide a row by right-clicking the row number on the left and selecting Hide. If you used 109, the subtotal should update again. If you used 9, it will not change.
  10. Verify the formula in the Formula bar. It must use SUBTOTAL, not SUM, AVERAGE, or any other function. If you see SUM, delete the formula and retype it correctly.

Common Mistakes

  • Using SUM instead of SUBTOTAL—they look similar but behave differently. SUM includes all rows, even hidden ones.
  • Including the SUBTOTAL cell in the range being calculated (e.g., =SUBTOTAL(9,B2:B101) if the formula is in B101). This creates a circular reference or returns zero.
  • Using 9 instead of 109 when manually hiding rows. If you hide rows by right-clicking and selecting Hide, only 109 will ignore them.
  • Applying SUBTOTAL to non-numeric data (text, dates without formatting, errors). SUBTOTAL only aggregates numbers.
  • Having merged cells in the data range. This can disrupt filtering and cause SUBTOTAL to skip rows or return #VALUE!.
  • Not applying a filter at all. SUBTOTAL does nothing unless rows are hidden via filtering or manual hiding.

Tips

  • Always use 109 (SUM, ignore all hidden) unless you specifically need to include manually hidden rows. It’s the most reliable for dynamic dashboards.
  • Convert your data range to an Excel Table (Ctrl+T) before using SUBTOTAL. Tables auto-expand and make filtering easier.
  • Use named ranges for your data (Formulas > Define Name) to make SUBTOTAL formulas easier to read and maintain.
  • Combine SUBTOTAL with AGGREGATE if you need to ignore error values (e.g., #DIV/0!)—AGGREGATE supports 19 functions and can skip errors entirely.
  • Use the Subtotal feature under Data > Subtotal (not the function) if you want Excel to auto-insert multiple subtotal rows for grouped data—but this creates static formulas, not dynamic ones.
  • Press Ctrl+~ (tilde) to toggle formula view and see if your cell contains SUBTOTAL or another function.

Troubleshooting

  1. If SUBTOTAL returns 0: Check if all visible rows contain zeros or blanks. Use a COUNTA function beside it to confirm there are actual values. Also verify the function number is correct—using 0 or 100 will return 0.
  2. If SUBTOTAL returns #VALUE!: Your range includes text, errors, or merged cells. Remove merged cells and ensure all cells in the range are numeric. Use =ISNUMBER() on each cell to test.
  3. If SUBTOTAL doesn't update when filtering: Make sure Filter is enabled on the column. Click the dropdown, reapply the filter, and ensure no text filters are set to "(Blanks)" if you want to include zeros.
  4. If the formula disappears after copying: SUBTOTAL is sensitive to relative references. Avoid copying the formula to a different column without adjusting the range. Use absolute references (e.g., $B$2:$B$100) if needed.
  5. If Excel crashes or freezes: You may have selected an entire column (e.g., B:B). Change the range to a specific subset (B2:B1000). Large ranges with SUBTOTAL can overload Excel.
  6. If nothing changes after hiding rows: Double-check whether you used 9 or 109. Try switching to 109 and re-hide a row manually.
  7. Restart Excel. Sometimes calculation settings get stuck. Go to Formulas > Calculation Options > Automatic.

Frequently Asked Questions

Why does SUBTOTAL give the same result as SUM?

You haven’t hidden any rows. SUBTOTAL only differs from SUM when rows are filtered or manually hidden. Apply a filter to see the difference.

Can I use SUBTOTAL with pivot tables?

No. Pivot tables have their own summary functions. Use the Value Field Settings to change aggregation from Sum to Average, Count, etc. SUBTOTAL does not work inside pivot table cells.

Does SUBTOTAL work with Excel Online?

Yes. SUBTOTAL functions fully support filtering and dynamic updates in Excel Online, just like the desktop version.

Why is my SUBTOTAL showing #NAME?

You’ve misspelled the function name. Check for typos like "Subtotal" or "Sub Totals". Excel requires exact spelling: SUBTOTAL in uppercase.

Can I use SUBTOTAL across multiple sheets?

No. SUBTOTAL only works within a single range on one sheet. For cross-sheet aggregation, use SUMIFS, SUMPRODUCT, or consolidate data into one sheet first.

What if I need to ignore #N/A or errors in the data?

Use AGGREGATE instead of SUBTOTAL. For example, use =AGGREGATE(9,3,B2:B100) to sum while ignoring all errors. The second argument (3) tells it to ignore errors.