The SUBTOTAL function in Excel calculates aggregations like SUM, AVERAGE, or COUNT on filtered data while ignoring other SUBTOTAL results, making it ideal for dynamic reports. Unlike regular functions (e.g., =SUM), it automatically skips hidden rows, ensuring accurate totals after filtering. No special setup is required beyond having data in a table or range with headers.

What You'll Need

  • A Microsoft Excel workbook (Excel 2010 or later, including Microsoft 365)
  • Your data organized in a contiguous range with clear column headers (e.g., "Product", "Region", "Sales")
  • At least one column containing numeric values to subtotal (e.g., sales amounts, quantities)

Step-by-Step

  1. Ensure your data has headers in the top row and no blank rows or columns within the dataset. Select any cell inside your data range.
  2. Go to the Data tab on the Excel ribbon.
  3. Click the Subtotal button in the Outline group. This opens the Subtotal dialog box.
  4. In the At each change in dropdown, select the column that defines your groups (e.g., "Region" if you want a subtotal for each region).
  5. In the Use function dropdown, choose the calculation type (e.g., Sum for totals, Average for means, Count for item counts).
  6. In the Add subtotal to list, check the box(es) for the column(s) you want to subtotal (e.g., check "Sales" to subtotal sales by region).
  7. Leave Replace current subtotals checked unless you’re adding to existing subtotals. Ensure Summary below data is selected for standard layout.
  8. Click OK. Excel inserts subtotal rows at each group change and displays the chosen function result.
  9. Use the outline symbols (gray numbers 1, 2, etc. on the left) to collapse or expand groupings. Clicking "1" shows only the grand total; "2" shows group totals; "3" shows all detail rows.

Common Mistakes

  • Applying Subtotal to unsorted data: The command groups by changes in the "At each change in" column, so data must be sorted by that column first (e.g., sort by Region before adding Region subtotals).
  • Subtotaling non-contiguous ranges: The tool only works on a single, continuous block of data. Gaps (blank rows/columns) cause incomplete grouping.
  • Using regular SUM instead of SUBTOTAL: Manual =SUM formulas won’t ignore hidden rows when filtering; SUBTOTAL (function_num 109) is required for filtered data.
  • Placing subtotals above data: If "Summary below data" is unchecked, totals appear above each group, which can confuse readers.
  • Forgetting to clear old subtotals: Re-running Subtotal without checking "Replace current subtotals" duplicates calculations.

Tips

  • Use Excel Tables (Ctrl+T) for dynamic ranges. Subtotals auto-adjust when you add/remove rows.
  • For dynamic filtering without permanent subtotals, use =SUBTOTAL(109, range) directly in a cell—e.g., =SUBTOTAL(109, C2:C100) sums only visible cells in C2:C100 after filtering.
  • Function numbers matter: 9–11 (SUM, AVERAGE, COUNT) include hidden rows; 109–111 ignore them. Use 109 for filtered reports.
  • Remove subtotals cleanly: Select any cell, go to Data > Subtotal, then click Remove All.
  • Combine with PivotTables for complex analyses. PivotTables offer more flexibility but Subtotal is faster for simple summaries.

Troubleshooting

If subtotals don’t appear or behave unexpectedly:

  • No outline symbols appear: Ensure your data has no blank rows. Insert a blank row between groups manually if needed, or fix sorting.
  • Incorrect totals: Verify data is sorted by the "At each change in" column before running Subtotal. Also, confirm the correct column is checked in "Add subtotal to".
  • Subtotal ignores filters: You likely used =SUM or SUBTOTAL with function numbers 1–11. Replace with 109 (for SUM) or 101 (for AVERAGE) to exclude hidden rows.
  • "Remove All" doesn’t work: The Subtotal dialog may be open. Close it, select a cell outside subtotals, then re-open Data > Subtotal > Remove All.
  • Formula errors (#DIV/0!, #NAME?): Check for non-numeric data in the subtotal column. Text values cause SUM to return 0; use COUNTA for text counts.

Frequently Asked Questions

Can I use Subtotal on filtered data without inserting rows?

Yes—use the =SUBTOTAL function directly in a cell. For example, =SUBTOTAL(109, A2:A100) sums visible cells only after applying AutoFilter, without adding subtotal rows.

Does Subtotal work with Excel Tables?

Yes, and it’s recommended. Convert your range to a Table (Insert > Table), then apply Subtotal. Totals update automatically when you add rows or change filters.

How do I subtotal multiple columns at once?

In the Subtotal dialog’s "Add subtotal to" list, hold Ctrl and click multiple column headers (e.g., "Sales", "Quantity", "Cost") before clicking OK.

Why does my subtotal show 0 even though data exists?

Check for hidden rows: right-click a subtotal row > Unhide. Also, ensure the column contains numbers—not text formatted as numbers (e.g., "123" instead of 123). Use =VALUE() to convert text.

Can I subtotal by multiple criteria (e.g., Region and Product)?

Yes, but run Subtotal in stages: first sort by Region and add Region subtotals, then sort by Product within each Region and add Product subtotals. Alternatively, use a PivotTable for nested groupings.

Is SUBTOTAL the same as the Subtotal tool on the Data tab?

No. The Data > Subtotal tool inserts rows with formulas and outline groups. The SUBTOTAL function is a worksheet formula (e.g., =SUBTOTAL(9, range)) you type manually. Use the tool for static reports; use the function for dynamic calculations.