SUBTOTAL function. Aggregate only the values displayed.(Microsoft Excel)

Japanese version.

Aggregate only the values displayed.

Aggregate functions, such as the SUM function, include all cells that are hidden by the filter.

However, the SUBTOTAL function excludes hidden cells from the total.

How it works

=SUBTOTAL(Function_num,ref 1 to 254)
NameOmissionSpecify
Function_numRequired.Aggregation Method. See below for details.
ref 1 to 254Only 1 is required.Specify a range of cells to be aggregated.

Function_num

Cells that are hidden by the filter are always excluded from the tally.

However, whether or not cells that are hidden by formatting are excluded depends on the value of the setting.

Aggregation Method.
(Include hidden.) 
Aggregation Method.
(Exclude hidden.)
Function
1101AVERAGE
2102COUNT
3103Count of non-blanks.COUNTA
4104MAX
5105MIN
6106PRODUCT
7107Sample standard deviation.STDEV
8108Standard deviation.STDEV.P
9109SUM
10110VAR
11111VARP

Example Results

It is mainly used for tables that use filter.

Cell C2 is a SUM function in the same cell range as the SUBTOTAL function.

Some cells were hidden by the filter.

The result of the SUBTOTAL function is now only the displayed cells, but the result of the SUM function remains the same.

This function can be applied to a range of cells.

---

Links

Microsoft Excel Functions Math & Trig