If you want to count filtered rows in Excel, you can do that using the SUBTOTAL function.
The SUBTOTAL function allows you to perform a regular count on a column with the ability to exclude those rows that have been filtered out.
In this short tutorial, I will show you how to use the SUBTOTAL function to count filtered rows in Excel, and another visual way to quickly identify the total number of filtered rows.
I’ll also cover the Total Row in Excel Tables, and a formula that counts only the filtered rows that meet a condition (something COUNTIF can’t do).
Follow along with the example file
Count Filtered Rows Excel.xlsx
Count Filtered Rows Using SUBTOTAL Function
Below is a data set where I have the employee’s name in column A, the department name in column B, and the location in column C, and I want the count of rows left after filtering in cell C12.

I have now applied a filter to this data set and filtered out the rows where the department name is Finance. So you get the dataset as shown below.

Now I want to get the count of filtered rows only.
Here is the SUBTOTAL formula that will give me the count of only those rows that are visible after the filtering is applied:
=SUBTOTAL(3,B2:B10)

The above formula gives us 6, which is the total number of rows that we have left after we have filtered the data set.
In the above SUBTOTAL function, we have used two arguments:
- 3 as the first argument – the first argument of the SUBTOTAL function always needs to be a numeric value that tells the function what kind of operation it needs to do on the following range. Using 3 here tells the function that it needs to give the count of the range (specified in the second argument) and skip the rows that have been filtered out.
- B2:B10 – this is the range on which the count is done.
Function number 3 does a COUNTA, which counts every cell that isn’t empty. So pick a column that has a value in every row (like the name or department column), because a blank cell in that column would not be counted.
Apart from the above formula, you can also use the below SUBTOTAL formula:
=SUBTOTAL(103,B2:B10)

The above formula also gives us 6. When you use 103, it also ignores rows you have hidden by hand (i.e., it does not count the hidden rows), even in an unfiltered dataset.
Note that these two arguments in the formula (3 and 103) work exactly the same when you use them with a filtered dataset. I cover the one case where they differ in the next section.
Also read: Select Visible Cells in Excel
SUBTOTAL 3 vs 103: Counting Rows You Hid Manually
The difference between 3 and 103 only shows up when you hide rows yourself (right-click the row number and choose Hide), instead of filtering them out.
Below is the same employee list, where I have hidden rows 5 and 9 by hand (no filter applied), and I want to count the rows that are still visible.

Here is the formula with 3 as the first argument:
=SUBTOTAL(3,B2:B10)

This gives us 9, even though only 7 rows are visible. When you use 3 and there is no filter, rows you hid manually are still counted.
Now here is the same formula with 103:
=SUBTOTAL(103,B2:B10)

This gives us 7, because 103 skips the rows you hid by hand.
But if you’re still confused about these two formulas, the table below should clear any confusion.
| Dataset Configuration | Using 3 | Using 103 |
|---|---|---|
| Rows not hidden and not filtered | Counts all rows | Counts all rows |
| Rows hidden manually, no filter | Hidden rows are counted | Hidden rows are not counted |
| Rows filtered (none hidden manually) | Only visible rows are counted. Filtered-out rows are not counted | Only visible rows are counted. Filtered-out rows are not counted |
| Filter applied, then more rows hidden manually | Only visible rows are counted. Filtered-out rows and hidden rows are not counted | Only visible rows are counted. Filtered-out rows and hidden rows are not counted |
In short, if you have a filtered dataset, both 3 and 103 will give you the same result.
The order you do things in also matters here. If you hide some rows by hand and then apply a filter, Excel shows those rows again if they match the filter, and then they get counted like any other visible row.
Since 103 counts only the rows you can see in every case, it’s the safer choice if you’re not sure how the rows got hidden.
Count Filtered Rows in an Excel Table (Total Row)
The above formulas would work with Excel Tables as well. But if your data is in a Table, there is an even easier way, as the Table’s Total Row can give you this count without typing any formula.
Below is the same employee list converted into an Excel Table, with the Finance rows filtered out, and I want the count of the visible rows in the Total Row below it.

Here are the steps to add a count of filtered rows using the Total Row:
- Select any cell in the Table, go to the Table Design tab, and check the Total Row option.

- Click the Total Row cell under the Department column, click the drop-down arrow that appears, and select Count.

The Total Row now shows 6. If you click on that cell, you’ll see that Excel has inserted the formula =SUBTOTAL(103,[Department]) for you, where [Department] refers to the Department column of this Table.
Since this is SUBTOTAL with 103, the count changes as soon as you change the filter, and it also skips any rows you hide manually.
When you turn on the Total Row, Excel may also add a total under the last column on its own. If you don’t need it, click that cell and choose None from its drop-down.
Count Filtered Rows That Meet a Condition
Sometimes you don’t just want the number of filtered rows, but the number of filtered rows that meet a condition. For example, how many of the visible employees are in Chicago.
Below is the same employee list with the Finance rows filtered out, and I want to count the visible rows where the location is Chicago (the location I typed in cell C12), with the result in cell C14.

The first thing you may try is the COUNTIF function:
=COUNTIF(C2:C10,C12)

This gives us 4, but only 2 of the visible rows are in Chicago. COUNTIF counts every matching cell in the range, including the ones in rows that have been filtered out.
And SUBTOTAL can’t help on its own, as it respects the filter but doesn’t take a condition. So we need to combine the two ideas.
Here is the formula that counts only the visible rows where the location is Chicago:
=SUM((C2:C10=C12)*MAP(C2:C10,LAMBDA(c,SUBTOTAL(103,c))))

This gives us 2 (Nolan Scott and Ethan Matthews), which are the only visible employees in Chicago.
How this formula works:
- (C2:C10=C12) – checks each location against Chicago and returns TRUE for a match and FALSE otherwise.
- MAP(C2:C10,LAMBDA(c,SUBTOTAL(103,c))) – the MAP function hands SUBTOTAL one cell at a time. SUBTOTAL(103,c) returns 1 if that cell’s row is visible and 0 if it is hidden, so you get a list of 1s and 0s.
- SUM(…) – multiplying the two lists gives 1 only for rows that are both visible and in Chicago, and SUM adds those 1s up.
The MAP and LAMBDA functions are available in Excel for Microsoft 365, Excel 2024, and Excel for the web.
If you are using Excel 2021 or an earlier version, use the below formula instead (in the example file, it’s in cell C15):
=SUMPRODUCT((C2:C10=C12)*SUBTOTAL(103,OFFSET(C2,ROW(C2:C10)-ROW(C2),0)))
This also gives 2. Here, the OFFSET function does the job MAP did in the earlier formula, by handing SUBTOTAL one cell at a time.
ROW(C2:C10)-ROW(C2) gives the list 0 to 8, and OFFSET moves down from C2 by each of those amounts. So SUBTOTAL gets C2, C3, and so on through C10, and returns 1 or 0 for each row, just like in the MAP version.
Pro Tip: OFFSET recalculates whenever anything in the workbook changes, which can slow down a big file. For large lists, enter =SUBTOTAL(103,C2) in cell D2, copy it down to D10, and then use =COUNTIFS(C2:C10,C12,D2:D10,1) instead.
Check the Count of Filtered Rows in the Status Bar
Not many Excel users know this, but the count of filtered rows is also shown in the status bar.
As soon as you apply a filter to your data set, you will notice that the status bar shows you how many records are visible after the filter from the total number of records.

Something like 6 of 9 records found – where 6 is the number of records visible after the filter has been applied and 9 is the total number of records in the data set.
Note that rows you hide by hand do not impact this. It only tells you how many records should be visible after the filtering, so if you manually hide any of the rows, that would still be counted.
You can also get this count by selecting the cells in any one column of your data, from the first data row to the last (a normal click-and-drag works, without the header).

The status bar now shows Count: 6. This Count only includes the visible cells in your selection, and it counts cells that aren’t empty, so pick a column with no blanks.
In this tutorial, I showed you how to use the SUBTOTAL function to count filtered rows in Excel. I covered the difference between the two arguments you can use in these SUBTOTAL functions.
And I have also covered the Total Row in Excel Tables, a formula to count filtered rows that meet a condition, and how to get the count of filtered rows through the status bar.
I hope you found this Excel tutorial useful.
Other Excel articles you may also like:
- Delete All Hidden Rows and Columns in Excel
- Filter By Color in Excel
- Paste into Filtered Column (Skipping Hidden Cells)
- Excel Filter Function
- Filter Cells that have Duplicate Text Strings (Words) in it
- Dynamic Excel Filter Search Box – Extract Data as you Type
- How to Count Colored Cells in Excel
- Count Rows Using VBA
- AGGREGATE Function in Excel
- Copy Visible Cells Only in Excel
Hi
Can you tell me the formula for identifying a specific set of text within a set of data and its number of occurances excluding flitered data.
Thanks