0
votes

I am trying to sum one column of numbers in Excel where the same text value is in Column A up until the sum of values in column C = 0. Here is an example:

     A       B        C          D
1  Issue   Action quantity      Net 
2  NFLX     Buy       25      some amount
3  NFLX     Sell     -25      some amount
4  NFLX     Buy       50      some amount
5  NFLX     Sell     -25      some amount
6  NFLX     Sell     -25      some amount
7  NFLX     Buy       50      some amount
8  AMZN     Buy       50      some amount
9  AMZN     Sell     -50      some amount

What I want to do is sum column D if the value of column A is the same up until the sum of column C is zero. I know I can use SUMIF to sum column D for the same values of column A. What I am not sure about is how to include the condition that the sum of all the values in column C from this row up above = 0. The summing would stop as soon as it reaches 0.

In the example above, it would sum rows 2-3, then rows 4-7, then rows 8-9.

1
So D2 = 25 D3 = 0 D4 = 50 D5 = 25 D6 = 0 D7 = 50 D8 = 50 D9 = 0Scott Craner

1 Answers

0
votes

Put this formula in D2:

=SUMIF($A$2:$A2,A2,$C$2:$C2)

And copy down.

enter image description here