SUBTOTAL
Calculates a subtotal for a list, ignoring filtered-out rows.
=SUBTOTAL(function_num, ref1, ...)This static page keeps the function indexed for search, while the spreadsheet app handles interactive exploration and saved formulas.
What the function does
Overview
Calculates a subtotal for a list, ignoring filtered-out rows.
The SUBTOTAL function is specifically designed for vertical ranges of data and is the standard for aggregate calculations in Excel Tables and filtered lists. Its primary advantage is its ability to automatically exclude rows hidden by a filter, ensuring the result reflects only what is visible to the user. Additionally, SUBTOTAL is programmed to ignore any other SUBTOTAL formulas within the reference range, effectively preventing double-counting in multi-layered reports. The um argument (1-11 or 101-111) determines the type of calculation and whether manually hidden rows (those hidden via right-click > Hide) are included. Constants 1-11 include manually hidden rows but exclude filtered-out rows, whereas 101-111 exclude both manually hidden and filtered-out rows. It is important to note that SUBTOTAL only reacts to hidden rows, not hidden columns. For modern workflows, using the 100-series codes (such as 109 for SUM) is considered best practice to ensure results remain consistent regardless of how data was hidden.
Quick reference
Syntax
=SUBTOTAL(function_num, ref1, ...)
Inputs
Arguments
Example: 9
Example: A2:A100
Formula patterns
Examples
sum visible rows in a filtered list
=SUBTOTAL(9, A2:A100)count non-blank visible cells excluding manual hides
=SUBTOTAL(103, B2:B50)calculate average of visible sales records
=SUBTOTAL(101, C2:C100)Avoid these issues
Common Errors
#VALUE!
Cause: The function_num argument is not an integer between 1-11 or 101-111, or a reference refers to a 3D range.
Fix: Verify that the first argument is a valid index code and ensure references are standard 2D ranges.
#DIV/0!
Cause: The specified aggregate (like AVERAGE or STDEV) is being calculated on a range where all values are filtered out or the visible range contains no numbers.
Fix: Check your filters to ensure some numeric data is visible or use IFERROR to handle empty results.
Platform support
Compatibility
Source: Microsoft Support
Common questions
Frequently Asked Questions
Calculates a subtotal for a list, ignoring filtered-out rows.
um: Operation ID (9=SUM) ref1: Range to calculate
#VALUE!: Verify that the first argument is a valid index code and ensure references are standard 2D ranges. #DIV/0!: Check your filters to ensure some numeric data is visible or use IFERROR to handle empty results.