
Tips.Net > ExcelTips Home > Worksheet Functions > Math and Trig Functions > Using the SUBTOTAL Function
Summary: One of the very versatile and flexible functions in Excel is SUBTOTAL. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, and Excel 2003.)
One of the built-in functions provided with Excel is SUBTOTAL. This function is used automatically by Excel if you use the Subtotals option from the Data menu (see the previous tip). If you learn to use the SUBTOTAL function by itself, however, you will find that it is very versatile and flexible. You can use it to procure more than just a simple subtotal, as the function name suggests.
The syntax for the SUBTOTAL function is as follows:
SUBTOTAL(function, refs)
In this syntax, the function is a value of 1 through 11, each representing a different way that SUBTOTAL can analyze your data. The settings have the following meanings:
| Function | Meaning | |
|---|---|---|
| 1 | AVERAGE | |
| 2 | COUNT | |
| 3 | COUNTA | |
| 4 | MAX | |
| 5 | MIN | |
| 6 | PRODUCT | |
| 7 | STDEV | |
| 8 | STDEVP | |
| 9 | SUM | |
| 10 | VAR | |
| 11 | VARP |
Notice that you are not limited to just totaling information; you can perform quite a few different calculations on your data. The function settings refer to different Excel functions (AVERAGE, COUNT, etc.) that are used, in turn, by the SUBTOTAL function.
The refs setting in SUBTOTAL means the cells or cell ranges to which the SUBTOTAL function should be applied. You can separate individual cell references by commas, and you can include up to 29 references (if desired).
The beauty of the SUBTOTAL function is that it ignores any other occurrence of the SUBTOTAL function in a range. Thus, if you used SUBTOTAL at the bottom of a column of values, and there were three other instances of SUBTOTAL in that column, the bottom SUBTOTAL would ignore the other three.
Another neat feature of SUBTOTAL is that it only works with displayed data. Thus, if you had some rows hidden or filtered rows, those are ignored in the calculation.
Tip #2048 applies to Microsoft Excel versions: 97 2000 2002 2003
PivotTables Got You Perplexed? PivotTables for the Faint of Heart shows how you can start using Excel's PivotTable tool right away to spin your data into gold! You discover how easy it really is to crunch the numbers you need to crunch. Uncover the power of creating PivotTables, editing them, formatting them, customizing them, and much more.
Check out PivotTables for the Faint of Heart today!
PivotTables don't need to be scary or mysterious. Use this powerful tool to analyze your data in ways you didn't know were possible. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Bugs and Pests Tips
ExcelTips
Family Tips
Health Tips
Home Tips
Organizing Tips
WordTips
Advertise on the
ExcelTips Site