The Excel subtotal formula shortcut instantly calculates aggregated values like sum, average, or count for visible rows only—perfect for filtered data. It skips hidden rows, making it ideal for dynamic reports. No add-ins or macros are required; this works in all modern Excel versions. Just select your data range and use the keyboard shortcut.

What You'll Need

  • A dataset with column headers and at least one column of numeric values to aggregate
  • Excel 2010 or later (works on Windows, macOS, and Excel for the web)
  • Filtered data (optional but recommended—subtotal works best when rows are hidden by filters)

Step-by-Step

  1. Click any cell within your data range. Ensure your data has headers and no blank rows within the table.
  2. Press Alt + = on Windows or Option + Command + = on macOS. This triggers Excel’s AutoSum feature, but only for visible cells if filters are applied.
  3. Excel will automatically insert the SUBTOTAL function into the cell below your last data row, in the same column. The function defaults to SUM (function_num 109).
  4. If you need a different calculation—like AVERAGE or COUNT—click the cell with the SUBTOTAL formula, then edit the formula manually. Change the first number inside the parentheses: use 101 for AVERAGE, 102 for COUNT, 103 for COUNTA, 104 for MAX, 105 for MIN, 106 for PRODUCT, 107 for STDEV, 108 for STDEVP, 109 for SUM, 110 for VAR, and 111 for VARP.
  5. Repeat steps 2–4 for each column you want to subtotal. Excel will place each subtotal directly below the last data entry in that column.
  6. Apply a filter to your data range by selecting any header cell, then pressing Ctrl + Shift + L (Windows) or Command + Shift + L (macOS). Filter any column to hide rows.
  7. Observe how the subtotal updates automatically to reflect only visible rows. Hidden rows are excluded from the calculation, even if they contain numbers.

Common Mistakes

  • Using regular SUM instead of SUBTOTAL: If you manually type =SUM(A2:A100), hidden rows are still included. SUBTOTAL with function_num 109–111 ignores hidden rows; SUM does not.
  • Inserting the shortcut in the wrong location: The shortcut only works if you’re inside a contiguous data range. If you click outside the table or in a blank cell next to it, Excel won’t detect the range and may sum unrelated cells.
  • Using function_num 9 instead of 109: Function_num 9 (SUM) includes hidden rows. Always use 109–111 to exclude hidden rows. Function_nums 1–11 behave like SUM and ignore filtering.
  • Not using headers: Excel may misidentify your data range if headers are missing, leading to incorrect subtotal placement or range selection.
  • Applying subtotal to non-numeric columns: If you use SUBTOTAL on text columns (e.g., names), functions like SUM or AVERAGE return 0 or #DIV/0! errors. Use COUNTA (103) for counting text entries.

Tips

  • Use the shortcut after filtering: Apply your filter first, then use Alt + = to ensure the subtotal reflects the current view.
  • Group multiple subtotals: After inserting one subtotal, select the entire row containing it, then copy and paste it into other columns. Adjust the function_num as needed.
  • Combine with PivotTables: For recurring reports, consider PivotTables—but SUBTOTAL is faster for one-off filters and doesn’t require restructuring data.
  • Use named ranges: If your dataset grows, convert it to an Excel Table (Ctrl + T). SUBTOTAL formulas automatically expand to include new rows.
  • Color-code subtotals: Highlight the subtotal row with a light background color to visually distinguish it from detail data.
  • Double-check function numbers: Keep a quick reference: 101=AVERAGE, 102=COUNT, 103=COUNTA, 109=SUM. Mistyping even one digit changes behavior.

Troubleshooting

  • The shortcut doesn’t insert anything: Make sure you’re inside the data range. Click a cell within the first row of your table, then try again. If that fails, manually type =SUBTOTAL(109, A2:A100) replacing the range with your actual range.
  • Subtotal shows 0 or #DIV/0!: You’re likely summing text or blank cells. Confirm the column contains numbers. If you need to count entries, use SUBTOTAL(103, range) instead.
  • Hidden rows are still counted: You used function_num 9 instead of 109. Edit the formula and change the first number to 109.
  • Subtotal appears in the wrong row: Excel may have misread your data range. Manually select the correct range in the formula bar, e.g., =SUBTOTAL(109, B2:B50).
  • Formula disappears after filtering: This is rare but can happen if Excel treats your data as non-structured. Convert your range to a Table (Ctrl + T) to lock in the range.
  • Excel crashes or freezes when using the shortcut: Restart Excel. If the issue persists, check for corrupted files by opening the workbook in Safe Mode (hold Ctrl while opening Excel).

Frequently Asked Questions

Can I use the subtotal shortcut on non-adjacent columns?

No, the shortcut works column-by-column. You must apply it separately to each column. For multiple columns, select the entire range and press the shortcut once—it will insert subtotals in all selected columns at once, provided they’re contiguous.

Does the subtotal formula work with manual row hiding?

Yes. SUBTOTAL with function_num 109–111 ignores both filtered-out and manually hidden rows. Right-click a row header and choose Hide—then check your subtotal. It updates automatically.

Can I use SUBTOTAL with other functions like IF or VLOOKUP?

Yes, but it requires nesting. For example: =SUBTOTAL(109, IF(A2:A100="Yes",B2:B100,0)) requires array entry (Ctrl+Shift+Enter in older Excel) or use SUMIFS instead for better performance.

What’s the difference between SUBTOTAL and AGGREGATE?

AGGREGATE is more powerful—it can ignore errors and nested subtotals too. But SUBTOTAL is simpler and sufficient for most filtering needs. Use AGGREGATE only if you’re handling error-prone data or nested totals.

Why does my subtotal change when I unfilter?

That’s the point. SUBTOTAL recalculates based on visible rows. When you unfilter, all rows become visible, so the sum includes everything. This is intentional behavior and not a bug.

Is the subtotal shortcut available in Excel for the web?

Yes. The keyboard shortcuts work the same. However, if you’re using a browser with custom keyboard mappings, test it first. If the shortcut doesn’t work, manually type =SUBTOTAL(109, range) instead.