Subtotals
The subtotal function in excel is very powerful. The syntax is SUBTOTAL(function_num, ref1, ref2, ...) The key for me is that the subtotal function does not include itself in other subtotal functions to avoid double counting.
What is also powerful is different types of function that can be performed.
Function_num Function
1 AVERAGE
2 COUNT
3 COUNTA
4 MAX
5 MIN
6 PRODUCT
7 STDEV
8 STDEVP
9 SUM
10 VAR
11 VARP
The SUBTOTAL function ignores any rows that are not included in the result of a filter, no matter which function_num value you use. That means you can combine the Data Filter facility and the Subtotal functions to summarise data as a result of the filtering.
The SUBTOTAL function is designed for columns of data, or vertical ranges. It is not designed for rows of data, or horizontal ranges. For example, when you subtotal a horizontal range using a function_num of 101 or greater, such as SUBTOTAL(109,B2:G2), hiding a column does not affect the subtotal. But, hiding a row in a subtotal of a vertical range does affect the subtotal.





