Use SUM when you want the total of a plain range of cells, and use SUBTOTAL when you want a total that ignores rows hidden by a filter, ignores other SUBTOTAL results nested inside your range, or gives you extra functions such as COUNTA, AVERAGE and MAX through the same formula. The practical difference shows up the moment you filter a table: a SUM keeps adding every row, while a SUBTOTAL recalculates to show only the visible ones. Both formulas are built into every current version of Excel on Windows, Mac, the web and mobile, and both take the same kind of range argument.
What You'll Need
- Any current version of Excel (Microsoft 365, Excel 2021 or later, Excel for Mac, Excel on the web, or the iOS/Android app). SUBTOTAL is not available in very old releases such as Excel 2003 and earlier.
- A data range with a header row if you plan to filter, so Excel knows which columns to treat as fields.
- Numbers stored as real numbers, not as text. A cell showing a small green triangle in its corner is usually text and will be ignored by both functions.
- For the filter examples below, your list converted to a table (Insert > Table) or AutoFilter switched on (Data > Filter). Labels in the ribbon can vary slightly by version, device and region.
Step-by-Step
- Lay out a small test block. Put labels in A1:C1, for example Region, Sales and Status. Enter five or six rows of data underneath with a couple of statuses such as Open and Closed. Keeping the data small at first makes it easy to see what each formula does.
- Write a plain SUM below the data. Click an empty cell and type
=SUM(B2:B7), then press Enter. This adds every numeric cell in that range, whether the row is visible or not. SUM takes one or more ranges separated by commas, so=SUM(B2:B7,D2:D7)also works for non-adjacent columns. - Write a SUBTOTAL next to it. In the cell beside your SUM, type
=SUBTOTAL(9,B2:B7)and press Enter. The 9 is the function number for SUM. At this point both cells show the same figure, which is expected because nothing is hidden yet. - Understand the function numbers before you rely on them. The first argument tells SUBTOTAL which calculation to run: 9 is SUM, 1 is AVERAGE, 2 is COUNT, 3 is COUNTA, 4 is MAX, 5 is MIN, 6 is PRODUCT and 7 is STDEV. Using 101 to 111 instead of 1 to 11 gives the same functions but also ignores manually hidden rows, not just filtered ones.
- Turn on a filter. Select your header row, then use Data > Filter. Drop-down arrows appear in each header cell. This step is what makes the difference visible.
- Filter to one value and compare. Click the arrow on the Status column and choose only Open. The SUBTOTAL cell updates to the total of the visible rows, while the SUM cell stays at the grand total. That gap is the whole point: SUBTOTAL respects the filter, SUM does not.
- Clear the filter and test manual hiding. Choose All from the same drop-down. Then right-click two row headers and pick Hide. The SUBTOTAL with 9 still counts those rows because they are not filtered out; change the formula to
=SUBTOTAL(109,B2:B7)and it will drop them. The 100-series is the version that ignores both filtered and manually hidden rows. - Try the built-in total row. If your range is an Excel table, tick Total Row on the Table Design tab. The total row uses SUBTOTAL automatically, so it keeps tracking the filtered data without you editing anything.
- Use AutoSum for speed. Select the empty cell directly under a column of numbers and press Alt+= on Windows, or use the AutoSum button on the Home tab. If that column already has SUBTOTALs above it, AutoSum generally produces another SUBTOTAL rather than a SUM, which avoids double counting.
- Copy the formula down a column. Drag the fill handle or copy and paste the SUBTOTAL formula beside each column you want totalled, changing only the range reference. Keep the function number the same so every column responds to the filter the same way.
- Check the grand total is still right. Put a final SUM somewhere outside the filtered block, pointing at the SUBTOTAL cells, to confirm the visible figures add up to the full total when no filter is applied.
Common Mistakes
- Totalling a range that contains SUBTOTAL results. SUM will double count the subtotals it finds inside the range, while SUBTOTAL deliberately ignores nested SUBTOTALs. If a total looks roughly twice as large as expected, this is usually why.
- Wrapping SUBTOTALs in a single SUM over the whole column. Adding up a long list of subtotal rows with SUM gives an inflated grand total. Point the grand total at the underlying data instead, or use a separate SUBTOTAL at the top level.
- Forgetting that SUBTOTAL must be typed on the sheet. It is a worksheet function, not something to look for in a ribbon menu, other than through the automatic table total row.
- Mixing function numbers. Using 2 (COUNT, numeric cells only) when you meant 3 (COUNTA, non-empty cells) gives a smaller count than expected because blank-looking cells containing formulas or spaces are skipped.
- Assuming SUBTOTAL hides manually hidden rows with the 1-9 numbers. It only respects filters unless you switch to the 101-111 series.
- Numbers stored as text. SUM and SUBTOTAL both ignore text-formatted numbers, so a total can come out short. Convert them with Text to Columns or by multiplying by 1 in a helper cell.
Tips
- Put a SUBTOTAL at the top of each column block as well as at the bottom if you work with long lists, so you can see the filtered figure without scrolling.
- Prefer Excel tables over plain ranges: they add structured references and a built-in total row that already uses SUBTOTAL.
- Use the 100-series numbers whenever anyone in the file might hide rows by hand, because it covers both filtered and hidden cases.
- Remember that SUBTOTAL works with AVERAGE, COUNT, COUNTA, MAX, MIN, PRODUCT and STDEV too, so one formula style handles most of your reporting needs.
- Name your ranges (Formulas > Define Name) if you reuse them across several sheets, which reduces reference errors when copying.
Troubleshooting
- The SUBTOTAL does not change when you filter. Check that the filter is actually applied to the same rows as the formula range, and that the formula is
=SUBTOTAL(9,range)rather than a function number below 1 or above 111. - You see #VALUE! Usually one of the range arguments is malformed, such as a missing comma or a stray space inside the reference. Retype the formula from scratch.
- Your total is too high. Look for other SUBTOTAL or SUM cells inside the range. Replace them with one top-level total pointing at the raw data.
- Your total is too low. Look for numbers stored as text, hidden rows if you used 101-111, or values entered outside the range reference.
- The total row appears twice. Some tables already contain a manual total beneath the table. Delete the duplicate rather than keeping both.
- If that did not work, rebuild the test block from Step 1 in a fresh sheet and compare behaviour there. If the simple version works and the real file does not, the problem is almost certainly in the data format or the range boundaries, not the formula.
Frequently Asked Questions
Is SUBTOTAL always better than SUM?
No. For a plain, static range that you never filter or hide, SUM is simpler and clearer. SUBTOTAL earns its place when rows will be filtered, hidden, or when subtotals exist inside the range.
What does the 9 in SUBTOTAL(9, range) mean?
It is the function number for SUM. The 100-series equivalent, 109, does the same but also ignores manually hidden rows.
Can I use SUBTOTAL without a filter?
Yes. Without a filter it behaves like SUM and adds every numeric cell in the range, so it is safe to build in from the start.
Why does SUBTOTAL ignore other SUBTOTAL cells?
By design. It skips nested SUBTOTAL results to prevent double counting, which is what lets you subtotal sections and total the subtotals safely with another SUBTOTAL.
Does SUBTOTAL work on Excel for Mac and the web?
Yes. The function exists on Excel for Mac, Excel on the web and the mobile apps, though menu names for filters and tables can differ slightly by version.
How do I count filtered rows instead of adding them?
Use =SUBTOTAL(3,range) for a count of non-empty visible cells, or =SUBTOTAL(2,range) for numeric cells only.