The SUBTOTAL function with SUMIF in Excel lets you sum values in a filtered list while ignoring hidden rows, making it perfect for dynamic reports where data is filtered by category, date, or region. Unlike regular SUMIF, SUBTOTAL respects row visibility, so only visible cells contribute to the total. You need a properly formatted table or range with headers and at least one column of numeric values to sum, and one column of criteria to match.
What You'll Need
- An Excel workbook with data organized in columns (preferably as a Table)
- A column containing values to sum (e.g., sales amounts)
- A column containing criteria to match (e.g., region names or product types)
- Filtering enabled on your data range (Data > Filter or Ctrl+Shift+L)
Step-by-Step
- Ensure your data is in a contiguous range with headers. If it’s not already a Table, select any cell in the range, then press Ctrl+T to convert it into an Excel Table. This ensures filtering works correctly and references stay stable.
- Apply a filter to your data by clicking the Filter button in the Data tab, or press Ctrl+Shift+L. Drop-down arrows will appear in your column headers.
- Click the drop-down arrow in the criteria column (e.g., Region) and select the value you want to sum (e.g., "North"). This hides all other rows.
- Click on an empty cell where you want the filtered sum to appear (e.g., below your data or in a summary section).
- Enter the formula: =SUBTOTAL(109, range_of_values_to_sum). Replace range_of_values_to_sum with the actual column range of numbers you want summed (e.g., C2:C100 if your sales amounts are in column C).
- After the SUBTOTAL function, add the SUMIF condition using an array formula structure. The full formula becomes: =SUMPRODUCT(SUBTOTAL(109, OFFSET(range_of_values_to_sum, ROW(range_of_values_to_sum)-MIN(ROW(range_of_values_to_sum)), 0, 1)), --(range_of_criteria=filter_value)).
- For example, if your sales values are in C2:C100, regions are in B2:B100, and you’ve filtered for "North", use: =SUMPRODUCT(SUBTOTAL(109, OFFSET(C2:C100, ROW(C2:C100)-MIN(ROW(C2:C100)), 0, 1)), --(B2:B100="North"))
- Press Enter. The result will show only the sum of visible rows matching "North", ignoring hidden rows.
- To change the filter, update the value in the formula (e.g., change "North" to "South") or use a cell reference like B125 to make it dynamic. If you use a cell reference, type: =SUMPRODUCT(SUBTOTAL(109, OFFSET(C2:C100, ROW(C2:C100)-MIN(ROW(C2:C100)), 0, 1)), --(B2:B100=$B$125)) and put your filter criteria in cell B125.
- Test the formula by filtering different values in your data. The sum should update automatically to reflect only visible rows.
Common Mistakes
- Using SUMIF alone without SUBTOTAL: this sums all rows, including hidden ones, defeating the purpose of filtering.
- Using SUBTOTAL(9, ...) instead of SUBTOTAL(109, ...): function_num 9 ignores manual row hides but includes rows hidden by filters; function_num 109 ignores both manually hidden and filtered rows — you need 109 for filtered data.
- Referencing entire columns (e.g., C:C) instead of a specific range: this can cause performance issues and incorrect results if extra data exists below your table.
- Forgetting the double negative (--) before the condition: --(B2:B100="North") converts TRUE/FALSE to 1/0 so SUMPRODUCT can multiply correctly. Without it, the formula returns 0.
- Not using OFFSET with ROW to create a dynamic array: without OFFSET, SUBTOTAL doesn’t return an array of visible values per row, making SUMPRODUCT fail.
Tips
- Convert your data to an Excel Table (Ctrl+T) to make ranges auto-expand as you add new rows — your formula will automatically include new data.
- Use named ranges for your value and criteria columns (Formulas > Define Name) to make formulas cleaner. For example, name C2:C100 as "Sales" and B2:B100 as "Region".
- For multiple criteria, nest additional conditions inside the SUMPRODUCT: --(B2:B100="North") * --(D2:D100="Q1") will sum only rows where region is "North" and quarter is "Q1".
- Always test your formula by hiding a row manually (right-click row number > Hide) and see if the sum drops accordingly — if it doesn’t, your function_num is wrong.
- Use conditional formatting on your summary cell to highlight when no data matches (e.g., if sum is 0 and filter is active, change background to yellow).
Troubleshooting
- If the formula returns 0: check that your filter value exactly matches the text in the criteria column (including spaces or case). Use TRIM and UPPER functions if needed: --(TRIM(UPPER(B2:B100))=UPPER("North"))
- If you get a #VALUE! error: ensure all ranges in the formula are the same size. If your sales range is C2:C100, your region range must also be B2:B100.
- If the sum doesn’t update after filtering: press F9 to recalculate. If that doesn’t help, check if Calculation is set to Automatic (Formulas > Calculation Options > Automatic).
- If the formula works in one cell but not another: verify you’re not referencing a protected or merged cell, and ensure no extra characters (like spaces) were accidentally copied into the formula.
- If performance is slow: limit your ranges to only the necessary rows. Avoid full-column references like C:C — use C2:C5000 instead if you have 5,000 rows.