Skip to main content

Count visible rows with criteria in Excel

It is easy to count only visible rows in a filtered list with the SUBTOTAL function. However, if you want to count visible rows with criteria, the SUBTOTAL function cannot help to achieve. You need to apply a formula based on the SUMPRODUCT, SUBTOTAL and OFFSET functions. This tutorial provides detailed steps to help you get through it.


How to count visible rows with criteria in Excel?

The below product table has been filtered by Shop A, to count only the visible Laptop in the Product column, you need to apply the below formula.

Generic Formulas

=SUMPRODUCT((range=criteria)*(SUBTOTAL(103,OFFSET(range_fiestcell,ROW(range)-MIN(ROW(range)),0))))

Arguments

Range: The range you will count only visible rows.
Criteria: The criteria you will count visible rows based on.
Vals.firstcell: The first cell of the range.

How to use these formulas?

1. Select a blank cell to output the result.

2. Enter the below formula into it and press the Enter key. Then the result is displayed in the selected cell.

=SUMPRODUCT((D3:D15=C18)*(SUBTOTAL(103,OFFSET(D3,ROW(D3:D15)-MIN(ROW(D3:D15)),0))))

Notes::

1) In the formula, D3:D15 is the range contains the visible rows to count, C18 contains the criteria you will count visible rows based on, and D3 is the first cell of the range. You can change them based on your own data.
2) If you did not enter the criteria in a cell in advance, you can directly enter it in the formula and enclose it in double quotes as follows.

=SUMPRODUCT((D3:D15="Laptop")*(SUBTOTAL(103,OFFSET(D3,ROW(D3:D15)-MIN(ROW(D3:D15)),0))))


Related functions

Excel SUMPRODUCT function
The Excel SUMPRODUCT function can be used to multiply two or more columns or arrays together, and then get the sum of products.

Excel SUBTOTAL function
The Excel SUBTOTAL function returns a subtotal in a list or database

Excel ROW function
The Excel ROW function returns the row number of a reference.

Excel MIN function
The Excel MIN function Returns the smallest number in a set of values.


Related formulas

Count Number Of Visible Rows In A Filtered List
This tutorial explains how to count number of visible rows in a filtered list in Excel with the SUBTOTAL function.

Count unique values in a range
This tutorial explains how to count only the unique values among duplicates in a list in Excel with specified formulas.

Count unique values with criteria
This step-by-step guide helps to count only unique values based on a specified criteria in another column

Use COUNTIF on a non-contiguous range
This step-by-step guide demonstrates how to use the countif function on a non-contiguous range in Excel.


The Best Office Productivity Tools


Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations