Sum first n cells

raikks

New Member
Joined
Feb 23, 2020
Messages
13
Office Version
2019
Platform
Windows
Hi - I need a formula that sums the first 3 cells of component1 that contains ``yes'' (result should be 88)
Also - I need to sum the first 3 cells of component1 & component2 that contains ``yes'' (result should be 121)
Thanks in advance.
 

Attachments

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

J.Ty.

Well-known Member
Joined
Feb 4, 2012
Messages
1,101
Office Version
365, 2013, 2010
Platform
Windows, Web
Hi,

Welcome to the Board!

Please test the following formula:

=SUMIF(A2:INDEX(A:A,SMALL(IF(A:A="yes",1,1000)*ROW(A:A),3)),"Yes",C2:INDEX(C:C,SMALL(IF(A:A="yes",1,1000)*ROW(A:A),3)))
You have to confirm it using Ctrl-Shift-Enter.
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
43,483
Office Version
365
Platform
Windows
First one:

=SUMIF(A2:INDEX(A2:A10,AGGREGATE(15,6,(ROW(A2:A10)-ROW(A2)+1)/(A2:A10="yes"),3)),"yes",C2:C10)

Have to go. Will come back to the second one later if not resolved.
 

raikks

New Member
Joined
Feb 23, 2020
Messages
13
Office Version
2019
Platform
Windows
Hi,

Welcome to the Board!

Please test the following formula:

=SUMIF(A2:INDEX(A:A,SMALL(IF(A:A="yes",1,1000)*ROW(A:A),3)),"Yes",C2:INDEX(C:C,SMALL(IF(A:A="yes",1,1000)*ROW(A:A),3)))
You have to confirm it using Ctrl-Shift-Enter.
Jesus - it works!
Thank you, sir!
 

raikks

New Member
Joined
Feb 23, 2020
Messages
13
Office Version
2019
Platform
Windows
First one:

=SUMIF(A2:INDEX(A2:A10,AGGREGATE(15,6,(ROW(A2:A10)-ROW(A2)+1)/(A2:A10="yes"),3)),"yes",C2:C10)

Have to go. Will come back to the second one later if not resolved.
Thank you, it works!
Would very much appreciate a solution for the second one as well.
 

J.Ty.

Well-known Member
Joined
Feb 4, 2012
Messages
1,101
Office Version
365, 2013, 2010
Platform
Windows, Web
Thank you, it works!
Would very much appreciate a solution for the second one as well.
Does the double "Yes" in the first row count as 2 or as 1 "Yes"?
 

raikks

New Member
Joined
Feb 23, 2020
Messages
13
Office Version
2019
Platform
Windows
I think it counts as 1 ``yes''.
I'll attach another pic to emphasize what I really want to sum up.
Let me know if it's clear.
 

Attachments

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
43,483
Office Version
365
Platform
Windows
Second one:

If you use a helper cell (G1 for me) with this formula:
=AGGREGATE(15,6,ROW(C2:C10)/((A2:A10="yes")*(B2:B10="yes")),3)
then
=SUMIFS(C2:INDEX(C:C,G1),A2:INDEX(A:A,G1),"yes",B2:INDEX(B:B,G1),"yes")


If you want without a helper then ..
=SUMIFS(C2:INDEX(C:C,AGGREGATE(15,6,ROW(C2:C10)/((A2:A10="yes")*(B2:B10="yes")),3)),A2:INDEX(A:A,AGGREGATE(15,6,ROW(C2:C10)/((A2:A10="yes")*(B2:B10="yes")),3)),"yes",B2:INDEX(B:B,AGGREGATE(15,6,ROW(C2:C10)/((A2:A10="yes")*(B2:B10="yes")),3)),"yes")
 

J.Ty.

Well-known Member
Joined
Feb 4, 2012
Messages
1,101
Office Version
365, 2013, 2010
Platform
Windows, Web
OK, here you go:
=SUMIFS(C2:INDEX(C:C,SMALL(IF((A:A="yes")+(B:B="yes")=2,1,1000)*ROW(A:A),3)), A2:INDEX(A:A,SMALL(IF((A:A="yes")+(B:B="yes")=2,1,1000)*ROW(A:A),3)),"Yes", B2:INDEX(B:B,SMALL(IF((A:A="yes")+(B:B="yes")=2,1,1000)*ROW(A:A),3)),"Yes")
Again use Ctrl-Shift-Enter.
 

raikks

New Member
Joined
Feb 23, 2020
Messages
13
Office Version
2019
Platform
Windows
Thank you once again - extremely helpful for me this formula.
 

Forum statistics

Threads
1,089,515
Messages
5,408,740
Members
403,224
Latest member
rholmesa

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...
Top