PDA

View Full Version : Sleeper: Conditional cumulative sum



pandres2002
10-01-2014, 06:59 AM
I am completely new to VBA, and I have limit expertise in Excel. So I need help!!!

I have three columns the first two are zones (integers), and the third is the value I want to cumulatively sum.

This are the first few values:
zoneA zoneB Values
row1 1 2 55
row2 1 2 13
row3 1 3 11
row4 1 4 2
row5 1 4 12

What I need, is to to sum the values of the third column (values) when the values of the first two columns (zone A, zone B) are the same. In the example, the results should be:

1 2 68
1 3 11
1 4 14

I need it to be presented in an excel worksheet as a result.

Thanks!!

Tom Jones
11-30-2014, 02:26 PM
Try
=SUMPRODUCT(($A$2:$A$6=1)*($B$2:$B$6=2)*($C$2:$C$6)) =68
=SUMPRODUCT(($A$2:$A$6=1)*($B$2:$B$6=3)*($C$2:$C$6)) =11
=SUMPRODUCT(($A$2:$A$6=1)*($B$2:$B$6=4)*($C$2:$C$6)) =14

where 1 is zoneA and 2, 3, 4 is zoneB

Zack Barresse
12-04-2014, 04:29 PM
why not just, assuming headers are in row 1, data starts in row 2...


=SUM(C1,IF(A2=B2,C2,0))