Sum first n cells

raikks

Board Regular
Joined
Feb 23, 2020
Messages
53
Office Version
  1. 2019
Platform
  1. 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

  • Untitled.png
    Untitled.png
    4.8 KB · Views: 18

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Good morning

=SUMPRODUCT((A$2:A$10="yes")*(C$2:C$10)*(ROW(B$2:B$10)<=SMALL((A$2:A$10<>"yes")*1000+ROW(A$2:A$10),3)))

=SUMPRODUCT((((A$2:A$10="yes")*($B$2:$B$10="yes"))*C$2:C$10)*(ROW(B$2:B$10)<=SMALL(((A$2:A$10<>"yes")+(B$2:B$10<>"yes"))*1000+ROW(A$2:A$10),3)))
 
Upvote 0
150 rows for the sheet where i needed this formula
In Excel terms that is a very small number so much better to have your formula only process a relatively small number of rows than whole columns where you would be dealing with over a million rows. So, for my formulas, something like these would easily cover it (allowing for data to row 500)

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

And for the second one, if you use the helper cell the helper cell formula in G1 would change to
=AGGREGATE(15,6,ROW(C2:C500)/((A2:A500="yes")*(B2:B500="yes")),3)
& the result formula stay the same as
=SUMIFS(C2:INDEX(C:C,G1),A2:INDEX(A:A,G1),"yes",B2:INDEX(B:B,G1),"yes")

Without the helper cell it would be
=SUMIFS(C2:INDEX(C:C,AGGREGATE(15,6,ROW(C2:C500)/((A2:A500="yes")*(B2:B500="yes")),3)),A2:INDEX(A:A,AGGREGATE(15,6,ROW(C2:C500)/((A2:A500="yes")*(B2:B500="yes")),3)),"yes",B2:INDEX(B:B,AGGREGATE(15,6,ROW(C2:C500)/((A2:A500="yes")*(B2:B500="yes")),3)),"yes")
 
Upvote 0

Forum statistics

Threads
1,215,222
Messages
6,123,706
Members
449,118
Latest member
MichealRed

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