You cannot nest SUBTOTAL inside SUMIF directly, because SUBTOTAL is built to ignore other SUBTOTAL results and SUMIF will either error or double-count depending on the layout. The workable approach is to combine SUMIF with SUMIFS criteria or to use SUMPRODUCT with SUBTOTAL's function number to sum only visible rows. The simplest reliable pattern is =SUMPRODUCT(SUBTOTAL(109,OFFSET(range,ROW(range)-MIN(ROW(range)),0,1)),--(criteria_range="value")), which returns the sum of a filtered list that also meets a condition. Set up your data as a proper table with a header row and no blank rows before you start.
What You'll Need
- Excel (desktop for Windows or Mac works best; the OFFSET/SUBTOTAL array formula is unreliable in Excel for the web and in some mobile versions).
- A data range with a single header row, no merged cells, and no entirely blank rows inside the block.
- Your data filtered with AutoFilter (Data > Filter) or formatted as a table, so rows can be hidden.
- Basic familiarity with entering a formula and pressing Enter, plus Ctrl+Shift+Enter if you are on an older Excel version.
Step-by-Step
- Lay the data out cleanly. Put column headers in row 1, data from row 2 down, and keep one blank column between your data block and any helper columns. Filtering and SUBTOTAL both misbehave when blank rows split the range.
- Turn on AutoFilter. Select any cell in the data, then go to Data > Filter. Filter arrows appear in the header row. Menu labels can differ slightly by version, device or region, but the Data tab and Filter button are consistent on desktop.
- Decide what SUBTOTAL should do. SUBTOTAL takes a function number as its first argument. Use 9 for SUM, 109 for SUM that ignores manually hidden rows, 3 for COUNTA, and 103 for COUNTA ignoring hidden rows. For a filtered list where you want only visible rows counted, use the 100-series numbers.
- Add a plain SUBTOTAL first to check your range. In an empty cell below your data, type =SUBTOTAL(109,D2:D100) where D is the amount column. Apply a filter and confirm the total changes as rows disappear. If it does not change, your range is wrong or the rows are hidden by something other than a filter.
- Add the SUMIF condition in a helper column instead of nesting. For each row, put a formula like =SUBTOTAL(109,$D$2:D2) in a helper column and copy it down. This produces a running total that only counts visible rows above and including the current row. Then use =SUMIFS(helper_range,criteria_range,criteria) to pull out the conditioned visible total. This is the most debuggable route because every intermediate value is visible.
- Or use the single-formula SUMPRODUCT approach. In a cell, enter =SUMPRODUCT(SUBTOTAL(109,OFFSET($D$2,ROW($D$2:$D$100)-ROW($D$2),0,1)),--($A$2:$A$100="North")). The OFFSET forces SUBTOTAL to evaluate one row at a time, the double unary turns TRUE/FALSE into 1/0, and SUMPRODUCT adds only rows that are both visible and match the criteria. Replace "North" with a cell reference such as $F$1 so you can change the condition without editing the formula.
- Press Enter and verify. On older Excel versions that do not support dynamic arrays, you may need Ctrl+Shift+Enter. Filter to a single category and compare the formula result with the status bar total (select the visible cells and read the Sum at the bottom right). If the two match, the formula is correct.
- Lock the ranges before copying. Make all data ranges absolute with $ signs so the formula still points at the same block when you paste it into other cells.
Common Mistakes
- Nesting SUBTOTAL inside SUMIF. SUMIF's range argument expects a flat range, not a function that returns an array. You will get a #VALUE! error or a wrong total. Use SUMPRODUCT with OFFSET, or the helper-column method.
- Using 9 instead of 109. Function number 9 ignores filtered-out rows but still includes rows hidden manually (right-click > Hide). If someone hid rows by hand, 9 counts them and 109 does not.
- Criteria that do not match exactly. SUMIF-style criteria are text-sensitive by default: "north" does not match "North". Wildcards like * and ? work for text, but numbers stored as text will not match numeric criteria.
- Blank cells inside the range. A blank row breaks the OFFSET/SUBTOTAL pattern and returns zeros for everything after it. Clean the data first.
- Forgetting that SUBTOTAL ignores other SUBTOTALs. If your helper column contains a SUBTOTAL, a grand SUBTOTAL over that column will skip it. That is deliberate and useful, but confusing if you did not expect it.
- Copying the formula to another sheet. OFFSET with relative references drifts unless every range is anchored with $.
Tips
- Format your range as a table with Ctrl+T first. Structured references make the formula easier to read and expand automatically when you add rows.
- Put the criteria value in its own cell (for example F1) and reference it, so you can change "North" to "South" without touching the formula.
- Use SUBTOTAL(103) alongside your sum to show how many visible rows match, giving you a count and a total in one view.
- For a simple total of visible rows only, a plain =SUBTOTAL(109,D2:D100) is enough and much faster than the array version. Only reach for the SUMPRODUCT pattern when you need the condition too.
- Test with a deliberately tiny filter first, such as a single category, so you can hand-check every value before trusting the result on the full dataset.
Troubleshooting
The formula returns zero. Check that the criteria range and the sum range are the same height and start on the same row. A one-row offset is the most common cause.
The total does not change when you filter. You are probably using 9 rather than 109, or the filter is not actually applied to the range SUBTOTAL covers. Click the filter arrow and confirm the box selections, then check the range end row.
You see #VALUE! or #NAME?. #NAME? usually means the function was typed with a typo or the workbook is in a locale that reads function names differently. #VALUE! usually means an array was passed where a single value was expected, which is the nesting problem described above.
The result is too high. Duplicate rows in the data, or a criteria range that is longer than the sum range, will inflate the total. Compare with a manual count of matching visible rows.
If that did not work, fall back to the helper-column method: it breaks the calculation into visible steps, so you can see exactly where the numbers diverge instead of debugging a single long formula.
Frequently Asked Questions
Can I put SUBTOTAL directly inside SUMIF?
No. SUMIF needs a range argument, not a function that returns an array. Use SUMPRODUCT with SUBTOTAL and OFFSET, or add a helper column with a running SUBTOTAL and sum that with SUMIFS.
What is the difference between SUBTOTAL 9 and 109?
9 ignores rows removed by a filter but still includes rows hidden manually. 109 ignores both filtered and manually hidden rows. Use 109 when you want a true visible-rows total.
Does this work in Excel for the web or on mobile?
The helper-column method works everywhere. The OFFSET/SUBTOTAL array formula can behave inconsistently in the web and mobile versions because they handle some array formulas differently, so test it before relying on it there.
Why does my SUBTOTAL total ignore some rows?
SUBTOTAL deliberately skips other SUBTOTAL formulas in the range to avoid double counting. If a column contains subtotals of subtotals, the outer formula will not add them.
Can I use several criteria with this method?
Yes. In the SUMPRODUCT version, multiply another set of parentheses, such as --($B$2:$B$100="Q1"), into the formula. Each extra condition is a separate block of parentheses multiplied together.