Using the SUBTOTAL Function

Written by Allen Wyatt (last updated December 10, 2022)
This tip applies to Excel 97, 2000, 2002, and 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. 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.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2048) applies to Microsoft Excel 97, 2000, 2002, and 2003.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Setting Gap Spacing in the Equation Editor

The Equation Editor is a great tool that allows you to add equations to your document. You have quite a bit of control ...

Discover More

Enlarging Icons on the Quick Access Toolbar

Tired of squinting when you look at icons on the Quick Access toolbar? It seems there is no relief from the eye strain, ...

Discover More

Rounding to a Half Hour and Formatting the Display

Excel is quite flexible in how it allows you to format and display times. However, some formatting and displaying can ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (menu)

Using the XIRR Function

One of the financial worksheet functions provided in Excel is the XIRR function. This is used to figure out an internal ...

Discover More

Rounding to the Nearest $50

When preparing financial reports, it may make your data easier to understand if you round it to the nearest multiple, ...

Discover More

Converting Radians to Degrees

When applying trigonometry to the values in a worksheet, you may need to convert radians to degrees. This is done by ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 2 + 2?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.