The SUBTOTAL function in Excel is a versatile tool that enables users to perform various mathematical calculations on a dataset, specifically tailored to handle filtered lists. This function stands out due to its capability to calculate totals while automatically excluding hidden rows, making it ideal for analysis where data visibility varies.
Syntax
The syntax for the SUBTOTAL function is as follows:
SUBTOTAL(function_num, ref1, [ref2], ...)
– function_num: A number between 1 and 11 or 101 and 111 that specifies which function to use (e.g., 1 for AVERAGE, 9 for SUM).
– ref1, ref2, …: One or more ranges or references on which the calculation is to be performed.
Check the table below for the functions that SUBTOTAL is using as inputs.

Examples
Here are three practical examples demonstrating how to use the SUBTOTAL function:
1. Calculating the Average of a Filtered List
To calculate the average of the visible rows in a data range from A1 to A10, use the following formula:
=SUBTOTAL(1, A1:A10)
In this case, `1` indicates that we are calculating the AVERAGE.
2. Summing Visible Rows Only
To sum only the visible rows in a list of sales data located in B1 to B20, the formula is:
=SUBTOTAL(9, B2:B10)
Here, `9` specifies the SUM function, ensuring that any hidden rows will not be included in the total. This is especially useful when you have a filter applied to a column and you don’t want to calculated hidden rows.

3. Counting Non-Empty Cells in a Filtered Range
To count the number of non-empty cells in a specific range, say C1 to C15, use:
=SUBTOTAL(3, C1:C15)
The `3` function number counts non-empty cells, again adhering to the filtered condition.
Error Handling
While using the SUBTOTAL function, consider the following potential errors:
– REF!: This error occurs when one of the references is invalid. Ensure that the specified ranges exist and are correctly formatted.
– VALUE!: This error may appear if you try to include non-numeric data in a calculation. Make sure that the data types in the specified ranges are compatible with the intended calculation.
– Hidden Rows Misinterpretation: Remember that SUBTOTAL only ignores rows hidden by filtering, not manually hidden rows. Therefore, it is essential to ensure that you are aware of how your data is organized.
Conclusion
The SUBTOTAL function is a vital feature in Excel for anyone dealing with large datasets, as it offers flexibility and precision in calculations. By utilizing this function, users can effectively manage data analysis without worrying about the inclusion of hidden rows, thereby enhancing the accuracy of their results. Whether you’re summing values, averaging data, or counting entries, SUBTOTAL provides an efficient way to handle filtered data seamlessly.