Subtotal a COUNTIF Range with an AutoFilter

Marhier

Board Regular
Joined
Feb 21, 2017
Messages
128
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Good day everyone.
I'm struggling to get my head around a bit of formula where I use a COUNTIF function, but have the result subtotal when a filter is applied.

I have a list of values in column V; my code currently just looks in that range and counts the amount of times the values are equal to or greater than "5":

Code:
=IFERROR(COUNTIF(V16:V1016,">5")+COUNTIF(V16:V1016,"5"),"")

I was wondering if someone could advise me on how to amend this formula so if an autofilter is applied, it then subtotals.
I feel is has something to do with SUMPRODUCT; I've looked on various forums and websites but struggling to apply anything to my code for it to work.

All help is greatly appreciated.
Thank you.
Kind regards
Marhier
 
Last edited:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I'm making some progress.
I've got it to work, but when the code that looks for values greater than 5, it's counting all the cells in the rage that are blank as well.

Any idea how to stop it from doing that.

Code is now:
Code:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(V16:V1016,ROW(V16:V1016)-MIN(ROW(V16:V1016)),,1))*(V16:V1016>5))
 
Last edited:
Upvote 0
Fixed it!
I was using COUNTA (3), rather than COUNT (2) as the subtotal.
There's a formula in all of column V that returns blanks and the COUNTA was counting the cells with formulas in.
COUNT just looks a cells with numbers in

Code is now:
Code:
=SUMPRODUCT(SUBTOTAL(2,OFFSET(V16:V1016,ROW(V16:V1016)-MIN(ROW(V16:V1016)),,1))*(V16:V1016>5))
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,193
Members
452,616
Latest member
intern444

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