Back to functions
Math & Trig2026-10-033 related articles

SUBTOTAL Function in Excel

Sum, average, count, or otherwise summarize a range while excluding filtered-out rows and optionally ignoring manually hidden rows.

Syntax

SUBTOTAL(function_num,ref1,[ref2],...)

Arguments

function_num

Required

A number from 1–11 or 101–111 that selects the calculation. Numbers 1–11 include manually hidden rows; 101–111 ignore them. Both exclude filtered-out rows.

ref1

Required

The first named range or reference to summarize.

ref2, ...

Optional

Additional named ranges or references, up to 254 references in total.

What it returns

Returns the result of the selected calculation for the included values in the references.

What SUBTOTAL does

SUBTOTAL summarizes a column of data and leaves out rows excluded by a filter. Use it when your total, average, or count needs to follow the rows selected in a filtered list.

The first argument chooses the calculation and tells Excel how to handle rows you hide manually. For example, 9 adds the values and includes manually hidden rows; 109 adds the values but excludes those rows. Both ignore filtered-out rows.

CalculationInclude manually hidden rowsIgnore manually hidden rows
AVERAGE1101
COUNT2102
COUNTA3103
MAX4104
MIN5105
PRODUCT6106
STDEV7107
STDEVP8108
SUM9109
VAR10110
VARP11111

Enter the number in the formula, not the calculation name. STDEV and VAR use sample calculations; STDEVP and VARP use population calculations.

Practical examples

Total the amounts before filtering

Enter these amounts in A2:A5, with the heading Amount in A1. Start with all four rows visible and no filter applied. Put the formula in C7, outside the data range.

CellAmount
A2120
A310
A4150
A523
=SUBTOTAL(9,A2:A5)

The result is 303: 120 + 10 + 150 + 23. Function number 9 selects SUM.

Compare manual hiding with filtering

Using the same four amounts, keep the filter cleared and manually hide worksheet row 3, which contains 10. Enter this formula in C8:

=SUBTOTAL(109,A2:A5)

The result is 293: 120 + 150 + 23. The formula with 9 in C7 still returns 303, because it includes manually hidden rows.

Now unhide row 3. Apply a filter to A1:A5 and exclude the value 10, leaving the other three amounts visible. The formulas with 9 and 109 now both return 293. Filtering excludes that row from either calculation.

Average the filtered amounts

Keep the same filter applied: A2 = 120, A4 = 150, and A5 = 23 are visible; A3 = 10 is filtered out. Enter this formula in C9:

=SUBTOTAL(101,A2:A5)

The result is 97.666…, or 97.67 when displayed to two decimal places: (120 + 150 + 23) / 3. Function number 101 selects AVERAGE and also excludes manually hidden rows.

Common mistakes and notes

Manual hiding and filtering are different

Choose 101–111 when manually hidden rows must be excluded. Changing to 1–11 includes manually hidden rows, but it never brings filtered-out rows back into the calculation.

Existing subtotals are skipped

If a referenced range contains another SUBTOTAL formula, SUBTOTAL ignores that nested result to avoid counting the same data twice.

Hiding columns does not have the same effect

SUBTOTAL is designed for vertical ranges. In a horizontal range such as =SUBTOTAL(109,B2:G2), hiding a column does not remove its value from the total.

References cannot span multiple worksheets

A 3-D reference, such as Sheet1:Sheet3!A2:A5, produces #VALUE!. Supply ranges on an individual worksheet instead.

Related functions

Related articles

Deep dives, troubleshooting guides, and practical examples that use SUBTOTAL.

Official documentation