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
- Click any cell within your data range. Ensure your data has headers and no blank rows within the table.
- Press Alt + = on Windows or Option + Command + = on macOS. This triggers Excel’s AutoSum feature, but only for visible cells if filters are applied.
- 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).
- 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.
- 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.
- 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.
- 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).