SubTotal

MARKEGANDERSON

Board Regular
Joined
Apr 7, 2007
Messages
243
Hello All-

I want to count all the "Yes", in a data range define as "CPR_Data", using the SubTotal function.

Can anyone help?
 

MARKEGANDERSON

Board Regular
Joined
Apr 7, 2007
Messages
243
thanks - This will count all the "YES" in "CPR_Data". I wanted it to count all the "YES" that's filtered. Reason why I wanted to use the subtotal function.

So combining your formula with the subtotal function would work, but I don't know how
 

Eric W

MrExcel MVP
Joined
Aug 18, 2015
Messages
8,966
If CPR_Data is a single column, then:

=SUM(IF(CPR_Data="yes",IF(SUBTOTAL(103,OFFSET(CPR_Data,ROW(CPR_Data)-ROW(INDEX(CPR_Data,1)),0)),1)))

with Control+Shift+Enter.
 

MARKEGANDERSON

Board Regular
Joined
Apr 7, 2007
Messages
243
Column T

=Data!$T:$T
 
Last edited:

MARKEGANDERSON

Board Regular
Joined
Apr 7, 2007
Messages
243
I replace the defined name CPR_data with T1:T9812, it works but counting everything in that range even if it is filtered. So Arrival week of 13 AUG has 13 "Yes" in column T. But when I filter by Week of 20 Aug which has 11 "Yes", it gives me a total of 24.

=SUM(IF(T1:T9812="yes",IF(SUBTOTAL(103,OFFSET(T1:T9812,ROW(T1:T9812)-ROW(INDEX(T1:T9812,1)),0)),1)))
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,138
I replace the defined name CPR_data with T1:T9812, it works but counting everything in that range even if it is filtered. So Arrival week of 13 AUG has 13 "Yes" in column T. But when I filter by Week of 20 Aug which has 11 "Yes", it gives me a total of 24.

=SUM(IF(T1:T9812="yes",IF(SUBTOTAL(103,OFFSET(T1:T9812,ROW(T1:T9812)-ROW(INDEX(T1:T9812,1)),0)),1)))
You need to confirm this formula with control+shift+enter.

The SUMPRODUCT array-processing equivalent which does not require control+shift+enter is...

=SUMPRODUCT(SUBTOTAL(103,OFFSET(T1:T9812,ROW(T1:T9812)-ROW(INDEX(T1:T9812,1)),0)),--(T1:T9812="yes"))<strike></strike>
 
Last edited:

Forum statistics

Threads
1,081,703
Messages
5,360,747
Members
400,595
Latest member
T_Dubs

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top