1
votes

enter image description here

I need to sum values in column A that meet certain criteria in column B until the next blank cell. The image (link above) shows the result I need: sums of all "A" for each three of the batches. I'm using this formula to calculate a total sum for each batch, and it works fine:

IF(A3="";SUM(A$1:A2)-SUM(C$1:C1);"")

But when I try to add SUMIF condition to this formula it doesn't work:

=IF(A3="";SUMIF(B:B;"A";A$1:A2)-SUM(D$1:D1);"")

What am I doing wrong?

1

1 Answers

0
votes

Sum if requires that the range sizes be the same.

Put this in C2 and copy down:

=IF(B3="",SUMIF($B$2:$B2,"A",$A$2:$A2)-SUM($C$1:C1),"")

If the value in B in the next row is a null string then it will do the SUMIF, if not it returns a null string.

The SUMIF is being done on all the values from row 2 to the row in which the formula is being placed. We are then subtracting the already counted values above where the formula is placed in column C to get the new sum.

enter image description here