## Summary

To count the number of visible rows in a filtered list, you can use the SUBTOTAL function. In the example shown, the formula in cell C4 is:

``````=SUBTOTAL(3,B7:B16)
``````

The result is 7, since there are 7 rows visible out of 10 rows total.

## Generic formula

``=SUBTOTAL(3,range)``

## Explanation

In this example, the goal is to count rows that are visible and ignore rows that are hidden. This is a job for the SUBTOTAL function. SUBTOTAL can perform a variety of calculations like COUNT, SUM, MAX, MIN, and more. What makes SUBTOTAL interesting and useful is that it automatically ignores items that are not visible in a filtered list or table. This makes it ideal for running calculations on the rows that are visible in filtered data.

### Count with SUBTOTAL

Following the example in the worksheet above, to count the number of non-blank rows visible when a filter is active, use a formula like this:

``````=SUBTOTAL(3,B7:B16)
``````

The first argument, function_num, specifies count as the operation to be performed. SUBTOTAL ignores the 3 rows hidden by the filter and returns 7 as a result, since there are 7 rows visible.

Note that SUBTOTAL always ignores values in cells that are hidden with a filter. Values in rows that have been "filtered out" are never included, regardless of function_num. If you are hiding rows manually (i.e. right-click > Hide), and not using filter controls , use this version of the formula instead:

``````=SUBTOTAL(103,B7:B16)
``````

With the function_num set to 103, SUBTOTAL still performs a count, but this time it will ignore rows that are manually hidden, as well as those hidden with a filter. To be clear, values in rows that have been hidden with a filter are never included, regardless of function_num.

The SUBTOTAL function can perform many other calculations. To see a list of all the calculations SUBTOTAL can perform, see this page.

Author

### Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.