The SUBTOTAL function in Excel calculates a total for a range of cells while ignoring rows that are hidden by a filter, which is exactly what makes it useful for tables you sort and filter. The basic syntax is =SUBTOTAL(function_num, ref1, [ref2], ...), for example =SUBTOTAL(9, B2:B100) to sum a column, or =SUBTOTAL(109, B2:B100) to also skip manually hidden rows. You enter it like any other formula: click the cell, type the formula, point at the range, and press Enter. The short version of the whole job is to pick the right function number, reference only the data rows (not the header or your own total row), and be aware of which rows the number you chose ignores.

What You'll Need

  • Excel on desktop (Microsoft 365, Excel 2021, 2019, 2016) or Excel for the web. The function works on all of them; the Function Arguments dialog described below is a desktop feature.
  • A table or list of data with one column of numbers you want to total.
  • A clear understanding of whether your rows will be hidden by filters, by hand, or both, because that decides which function number you need.

Step-by-Step

  1. Lay out your data cleanly. Put column headings in row 1 and data below, with no blank rows inside the range and no text mixed into the number column. SUBTOTAL ignores text in a sum, but stray blank rows can split the range and give a misleading result.
  2. Pick the cell for the total. Place it directly under the column you are adding, or in a separate summary area. Do not put the total inside the range you are about to reference, or you create a circular reference.
  3. Decide the function number. The first argument tells Excel which calculation to perform. The most common are 9 for SUM, 1 for AVERAGE, 2 for COUNT, 3 for COUNTA, 4 for MAX, and 5 for MIN. Add 100 to any of these (109, 101, 102, and so on) to make the formula ignore rows you hid manually as well as rows hidden by a filter.
  4. Type the formula. In the total cell, type =SUBTOTAL(, then the function number, a comma, the range, and a closing bracket. For example, =SUBTOTAL(9, C2:C50) sums the visible values in C2 through C50 after filtering.
  5. Or build it with the dialog. On Excel desktop, start typing =SUBTOTAL( and click the function name when Excel offers it, or press Ctrl+A while the cursor is inside the function name to open the Function Arguments dialog. The dialog lets you pick the function from a list by name instead of remembering the number, and you can drag over the range to fill the Ref1 box.
  6. Press Enter and check the result. Compare the SUBTOTAL figure against a plain SUM of the same range while nothing is filtered. With no rows hidden, the two should match. If they do not, you have probably included a header, a blank, or the total row itself in the range.
  7. Test the filter behaviour. Apply a filter to a heading (select the data, then use Data > Filter), hide a few rows with the filter dropdowns, and confirm the SUBTOTAL figure changes while a plain SUM in another cell stays the same. That difference is the whole point of the function.
  8. Decide about manually hidden rows. If you hide rows by right-clicking and choosing Hide rather than filtering, function number 9 will still include them. Use 109 if you want those rows excluded too. Choose one convention and keep it consistent down the column so your totals are comparable.
  9. Copy the formula across columns if needed. Drag the fill handle to the right and the relative reference shifts from C2:C50 to D2:D50 and so on. The function number stays fixed because it is a constant, not a reference.
  10. Add a grand total if you have several subtotals. If you have three section totals at rows 10, 20, and 30, do not SUM the section totals with a plain SUM if those sections can be filtered. Instead total the underlying detailed range with SUBTOTAL, or sum the three subtotal cells directly if they are always visible.

Common Mistakes

  • Including the header row. A range like C1:C50 pulls the word "Amount" into a COUNTA and, more importantly, makes it easy to accidentally include the total cell too.
  • Referencing the total cell itself. A circular reference warning means your range contains the formula cell. Shrink the range until it stops before the total row.
  • Using 9 when you meant 109. Filter-hidden rows are ignored by both, but manually hidden rows are only ignored by 109. If your total looks too high after hiding rows by hand, this is usually why.
  • Mixing function numbers down a column. One row using 9 and the next using 109 gives totals that behave differently when filtered, which makes comparing them meaningless.
  • Forgetting that SUBTOTAL ignores other SUBTOTALs. Nested or stacked SUBTOTAL results inside the referenced range are skipped, so a grand total built from a range that already contains subtotals will not double-count. That is a feature, but it can surprise you if you expected a straight addition.
  • Assuming it works with COUNTBLANK-style logic. SUBTOTAL handles the functions in its list only. It cannot do conditional sums like SUMIF; that is a different function.

Tips

  • Use SUBTOTAL as the bottom row immediately after converting your data to an Excel Table (Insert > Table). Tables add filter dropdowns automatically and expand as you add rows.
  • Use 109 rather than 9 as your default when you expect to hide rows manually for presentation purposes.
  • Format the total cell differently (bold, a top border) so it is obvious at a glance which cell is the summary and not another data row.
  • Keep the function number in a visible way—many people add a comment to the total cell noting "109 = sum, filter and manual hides" so the next editor does not break it.
  • If you need the total to update for criteria as well as filters, combine SUBTOTAL not with SUMIF but with a helper column that flags matching rows, then filter on that flag.

Troubleshooting

If the total is wrong by exactly one row's worth, check whether your range includes the header or the total itself. If the total does not change when you filter, you probably used SUM instead of SUBTOTAL; look at the formula bar to confirm. If you see #VALUE!, the first argument is not a valid function number or the range text has been entered as a string. If the cell shows a circular reference warning, your range includes its own cell—reduce it. If the total stays the same after you hide rows by hand, switch 9 to 109. If a filtered total shows zero, verify the number column really contains numbers rather than numbers stored as text; select the column and use Data > Text to Columns then Finish to convert them, or re-enter them as values. If your range has grown because you added rows below the total, move the total to the end of the data or convert the range to a Table so the reference expands automatically.

Frequently Asked Questions

What is the difference between SUBTOTAL 9 and 109?

Both sum a range and both ignore rows hidden by a filter. The 109 version also ignores rows you hid manually, such as by right-clicking and choosing Hide. Use 9 if you want hand-hidden rows counted; use 109 if you want them excluded.

Does SUBTOTAL work with AVERAGE and COUNT?

Yes. Function number 1 is AVERAGE, 2 is COUNT, 3 is COUNTA, 4 is MAX, and 5 is MIN. Add 100 to each to also exclude manually hidden rows. This lets you show a filtered average or count alongside a filtered sum.

Why does my SUBTOTAL not change when I filter?

Most often the formula is actually a plain SUM, or the range does not cover the rows you are filtering. Select the total cell and read the formula bar to confirm it starts with =SUBTOTAL(.

Can I use SUBTOTAL inside a larger formula?

You can, for example dividing one SUBTOTAL by another to get a share of the visible total. Keep each SUBTOTAL self-contained with its own range and function number so the result stays predictable.

Does SUBTOTAL ignore text and blanks?

The sum version ignores text and blanks. The count version (2) counts only numeric cells, while COUNTA (3) counts non-empty cells including text. Pick the number that matches what you want counted.

Can I use SUBTOTAL on a Mac or in Excel for the web?

Yes, the function itself is identical. The Function Arguments dialog is available on desktop Excel for Mac and Windows; on Excel for the web you type the arguments directly into the formula bar.