Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Counting Filtered Rows.

# Counting Filtered Rows

by Allen Wyatt
(last updated March 12, 2016)

John has applied a filter to the contents of one of his worksheets. He wants to determine the count of rows visible in the filtered data, but when he tries to count them using the COUNT function, Excel returns the overall number of rows, including those not displayed in the filtered list.

This is actually normal behavior—the COUNT function returns all the rows in a range, whether they are visible or not. If you want to determine the number of rows that meet the criteria of your filter, there are a variety of techniques you can use.

If you don't need to get your count in a cell, then you can simply rely upon Excel to inform you of the count. When you apply a filter, the Excel status bar contains a count of how many rows are displayed by the filter. This count disappears as soon as you start editing other information in your worksheet, but it will reappear if you reapply the filter.

You could also select all the visible cells in a particular column and just look in the "totals" area of the status bar. By default Excel displays the sum of whatever cells you've selected, but you can right-click on this sum and instead instruct Excel to display a count of the selected cells.

If you want to use a formula to determine the row count, you could use the COUNTIF function. All you would need to do is make sure that the criterion specified in the function is the same criteria that you used in your filter. The drawback to this, of course, is that if you change your filter criteria you will also need to change the COUNTIF criteria to get an accurate count.

You can also use the SUBTOTAL function to determine the count of rows. For instance, if your filtered information was in A2:A500, you could use this formula to display a count of the rows displayed by the filter:

```=SUBTOTAL(2,A2:A500)
```

The first parameter, 2, indicates that you want Excel to use the COUNT function to determine the formula result. If you change this parameter to 3 then SUBTOTAL will use COUNTA instead. Either way, SUBTOTAL only counts those rows displayed by the filter.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11500) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Counting Filtered Rows.

##### 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

Many businesses organize information according to calendar quarters, especially when it comes to fiscal information. ...

Discover More

Turning Off Comment Color when Printing

Comments that you add to your document are most often displayed in a bright color so they aren't easily missed. If you ...

Discover More

Entering a Name in the Header of a Locked Form

When you lock a document as a form, then Word limits what you can do with that document. That includes not being able to ...

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 (ribbon)

Displaying Multiple Filtered Colors

The filtering capabilities of Excel are quite helpful in taming a large amount of data. While you can filter by color, ...

Discover More

Finding Rows with Values in Two Columns

When you use Excel to input and store information, you need to be concerned with whether the information meets your ...

Discover More

Showing Filter Criteria on a Printout

When you print out a filtered worksheet, you may want some sort of printed record as to what filtering was applied to the ...

Discover More
##### Subscribe

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

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}] 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 eight minus 8?

2016-09-09 09:42:19

Hamisch Fisher

Great tip! Most of the spreadsheets I work with are used by somebody else (though in the same workplace). Because of the less than stellar error handling in Excel, I usually try to write VBA that is not likely to produce errors. I am embarrassed to say it but until a few days ago, I didn't know that deleting visible rows after using a filter (when no records exist) produces a run time error. The ability to use code to know how many rows remain helps me avoid that problem.

##### This Site

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