Count total Number of filtered rows including empty cells

DADAZHU

New Member
Joined
Aug 9, 2011
Messages
37
Hi, everyone,

I've been trying to find a way to show number of filtered rows included rows with empty cells. I had no luck so far.

I have a simple table, with value only "Y" or nothing Under columns C,D,E,F, and G, similar like this,

A B C D E F G
1 Area Type 1 2 3 4 5
2 SYD H Y Y
3 MEL I Y
.

The title of the table(row 1) gets filtered, at bottom of the table, I have no problem to get the number of rows with "Y", eg

=SUMPRODUCT(SUBTOTAL(3,OFFSET(F$2:F$120,ROW(F$2:F$120)-MIN(ROW(F$2:F$120)),0,1)),--(F$2:F$120="Y"))

I am unable to get number of filtered rows with no value, or the total number of filtered rows. I am able to get the info via VBA, but in this instance, no VBA is allowed. One of unsuccessful attempts was as below,
=SUMPRODUCT(SUBTOTAL(3,OFFSET(F$2:F$120,ROW(F$2:F$120)-MIN(ROW(F$2:F$120)),0,1)),--(F$2:F$120="")) , the return was 0. I am not sure it wasn't working.


I think that the solution should be easy, but I've been pulling my hair and making no progress on it.

Your help will be appreciated.

Regards,

David
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi, everyone,

I've been trying to find a way to show number of filtered rows included rows with empty cells. I had no luck so far.

I have a simple table, with value only "Y" or nothing Under columns C,D,E,F, and G, similar like this,

A B C D E F G
1 Area Type 1 2 3 4 5
2 SYD H Y Y
3 MEL I Y
.

The title of the table(row 1) gets filtered, at bottom of the table, I have no problem to get the number of rows with "Y", eg

=SUMPRODUCT(SUBTOTAL(3,OFFSET(F$2:F$120,ROW(F$2:F$120)-MIN(ROW(F$2:F$120)),0,1)),--(F$2:F$120="Y"))

I am unable to get number of filtered rows with no value, or the total number of filtered rows. I am able to get the info via VBA, but in this instance, no VBA is allowed. One of unsuccessful attempts was as below,
=SUMPRODUCT(SUBTOTAL(3,OFFSET(F$2:F$120,ROW(F$2:F$120)-MIN(ROW(F$2:F$120)),0,1)),--(F$2:F$120="")) , the return was 0. I am not sure it wasn't working.


I think that the solution should be easy, but I've been pulling my hair and making no progress on it.

Your help will be appreciated.

Regards,

David

Is there a column that will always have data (no blanks)? I realize you may be filtering from a column that may not have data in some rows.

A clearer example will be helpful.
 
Upvote 0
If this correctly gives you the number of filtered rows with Y,

=SUMPRODUCT(SUBTOTAL(3,OFFSET(F$2:F$120,ROW(F$2:F$120)-MIN(ROW(F$2:F$120)),0,1)),--(F$2:F$120="Y"))

Then unless my brain is falling out of my head again, this should count all the filtered rows.

=SUMPRODUCT(SUBTOTAL(3,OFFSET(F$2:F$120,ROW(F$2:F$120)-MIN(ROW(F$2:F$120)),0,1)))
 
Upvote 0
If this correctly gives you the number of filtered rows with Y,

=SUMPRODUCT(SUBTOTAL(3,OFFSET(F$2:F$120,ROW(F$2:F$120)-MIN(ROW(F$2:F$120)),0,1)),--(F$2:F$120="Y"))

Then unless my brain is falling out of my head again, this should count all the filtered rows.

=SUMPRODUCT(SUBTOTAL(3,OFFSET(F$2:F$120,ROW(F$2:F$120)-MIN(ROW(F$2:F$120)),0,1)))
That doesn't include the empty cells:
I've been trying to find a way to show number of filtered rows included rows with empty cells.
I don't think this can be done unless you use an "anchor" column to base the count on.

For example:

Book1
AB
1RegionComplete
2SouthY
3EastY
4North_
5East_
6NorthY
7West_
8NorthY
9SouthY
10NorthY
11East_
12East_
13EastY
14South_
15EastY
16EastY
17SouthY
18South_
19EastY
20East_
Sheet1

You could base the count on visible rows when filtered by region.

Yo could add a helper column to be used as the anchor column if need be.
 
Upvote 0
Solved -- Count total Number of filtered rows including empty cells

Thanks all for your help.

To Steve, COUNTA(Range)+COUNTBLANK(Range) will only give me the total rows before the table is filtered. But I actually look for the total number of rows being filtered.

To jonmo1, as T. Valko said, it will only give me the numbers of rows with "Y", doesn't include the those empty cells.

To T. Valko & crusader, both columns(Area & Type) always have data, so I now decide to use one of them as the "anchor" column. ;)
 
Upvote 0
Re: Solved -- Count total Number of filtered rows including empty cells

Picking up my brain....:rofl:

So you could use the same basic formula, without the ="Y" criteria.
But referenceing a column that does not contain blanks.

=SUMPRODUCT(SUBTOTAL(3,OFFSET(F$2:F$120,ROW(F$2:F$120)-MIN(ROW(F$2:F$120)),0,1)))

Change all the references to column F to whatever column does not contain any blanks.
 
Upvote 0
Yes, Jon, I did exactly the same as you mentioned, no need for an additional criteria.

To Steve, I could be wrong, but I think only Subtotal can do the trick when the filter is on..

Cheers
 
Upvote 0
Re: Solved -- Count total Number of filtered rows including empty cells

Thanks all for your help.

To Steve, COUNTA(Range)+COUNTBLANK(Range) will only give me the total rows before the table is filtered. But I actually look for the total number of rows being filtered.

To jonmo1, as T. Valko said, it will only give me the numbers of rows with "Y", doesn't include the those empty cells.

To T. Valko & crusader, both columns(Area & Type) always have data, so I now decide to use one of them as the "anchor" column. ;)
Ok, then using column A Area as the anchor column:

=SUMPRODUCT(SUBTOTAL(3,OFFSET(A2,ROW(A2:F120)-ROW(A2),0,1)))
 
Upvote 0

Forum statistics

Threads
1,224,617
Messages
6,179,914
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top