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.
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.
Learn more about Allen...
Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Counting Displayed Cells.
The filtering capabilities of Excel make it easy to display just the information that you want from a data table. How you use filtering has been discussed in other issues of ExcelTips. Once you've applied a filter to your data, you may want to use a function to display the number of cells that are displayed in a filtered range.
If you just need to quickly know the count, highlight the filtered range, right-click anywhere on the status bar, and choose Count from the resulting Context menu. Excel displays, in the status bar, the number of cells displayed in the range you selected.
If you need a solution that you can use in a formula, you should look towards the SUBTOTAL function. This function provides a number of different "subtotal" results, but it only operates on data that is displayed. This means that the information filtered out by AutoFilter won't count in what SUBTOTAL returns.
The general syntax of the SUBTOTAL function is as follows:
All you need to do is specify a type and a range. The range part should be easy: it is just a standard range. The type specifier can be a number between 1 and 11, as follows:
Notice that the type specifier you use indicates what Excel function is applied to the displayed results. Thus, if you want to determine the count of the filtered results in the range of F3:F27, you would use a type specifier of 2, as follows:
This usage will, of course, count numeric values in the range specified. If you want to count text values, then you should use a type specifier of 3 so that Excel relies on the COUNTA function instead.
You should also know that you can use type specifiers in the range of 101 to 111; they are the same as the specifiers listed above, but only have 100 added to them. The difference is that the values 1 through 11 operate on all cells, whereas the values 101 through 111 operate on only the non-hidden cells. This secondary range of specifiers is supported in Excel 2003, but may be supported in some earlier versions of Excel, as well. (Best way to find out? Try them and see if the function crashes for you or not.)
If you are the type of person that prefers a macro-based solution, then you may want to refer to the Microsoft Knowledge Base, article 213330 for a fuller discussion:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (1955) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Counting Displayed Cells.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!