Returns a subtotal in a list or database. Can perform 11 different aggregate functions and optionally ignore hidden rows.
Master the fundamentals of Excel SUBTOTAL function
SUBTOTAL performs 11 aggregation operations (SUM, AVERAGE, COUNT, etc.) on ranges of data, with optional capability to ignore hidden rows. Uses function numbers 1-11 to include hidden rows or 101-111 to exclude hidden rows.
SUM, AVERAGE, COUNT, COUNTA, MAX, MIN, PRODUCT, STDEV, STDEVP, VAR, VARP
1-11 include hidden, 101-111 exclude hidden
Doesn't double-count nested subtotals
Perfect for filtered data analysis
Function-specific parameters
Function-specific return type
Analyze visible filtered data
Cascading subtotal reports
Toggle between visible/all data
Exact matching required
Returns numeric position
Handles missing text gracefully
=SUBTOTAL(function_num, ref1, ref2, ref3, ...)Number 1-11 or 101-111 specifying function (1-11 include hidden rows, 101-111 exclude hidden rows)
First range or reference for subtotal calculation
Additional ranges (up to 254) to include in subtotal
Result from specified aggregation function
Description: Calculates subtotals with optional hidden row filtering
Sum values including hidden rows
Uses SUM (9), includes hidden rows
Simple VBA usage
Sub UseSubtotal()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
' Sum including hidden rows (function 9)
ws.Range("C1").Value = Application.WorksheetFunction.Subtotal(9, ws.Range("A1:A100"))
' Sum excluding hidden rows (function 109)
ws.Range("C2").Value = Application.Subtotal(109, ws.Range("A1:A100"))
End SubAnalyze visible data
Toggle visible/all
Unexpected values
Verify hidden row settingSolution: Check function_num; 1-11 vs 101-111 matter