FormulaCamp
Completed
← Google Sheets functions
Google Sheets function

SUBTOTAL in Google Sheets

SUBTOTAL with worked examples you can test in the live grid. The argument details are in the Excel guide.

In Google Sheets

The arguments and common errors are covered in the SUBTOTAL Excel guide; check the function help in Google Sheets for its own argument list.

Worked examples in Google Sheets

Sum code

A
1Value
22
34
46
58

Formula: C2: =SUBTOTAL(9,A2:A5)

Result: 20

Code 9 selects SUM for the referenced values.

Count code

A
1Value
22
34
46
58

Formula: C2: =SUBTOTAL(2,A2:A5)

Result: 4

Code 2 counts the numeric cells.

A nested subtotal is skipped

A
1Amount
23
34
4=SUBTOTAL(9,A2:A3)

Formula: C2: =SUBTOTAL(9,A2:A4)

Result: 7

A4 is itself a subtotal of 7, so it is not added again. SUM(A2:A4) would give 14.

Try it

A tiny spreadsheet with example data. Edit the formula or any number and see the result.

Formula in F2: =SUBTOTAL(9,C2:C7)

Example spreadsheet for SUBTOTAL
ABCDEF
1RegionProductUnitsPriceResult
2EastPen1202.5350
3WestPen802.5
4EastBook4512
5NorthBook6012
6WestLamp3025
7EastLamp1525
Result in F2: 350
Practice this in a lesson: Filter and SUBTOTAL

Google Sheets is used here only as a descriptive product name. FormulaCamp is not affiliated with Google.