0
votes

I'm trying to write an excel formula to sum every second row in given column but only if the cell below/above is not empty.

My excel table is as follows:

      A           B         C
1   Group1      First       3
2               Second      9
3   Group2      First       -
4               Second      8
5   Group3      First       4
6               Second      -

7   Sum         Firsts      <formula1 - should ignore Group3 because its Second cell is empty>   
8               Seconds     <formula2 - should ignore Group2 because its First cell is empty>
1
Are the cells empty or dashed? - basic
@basic they are empty not dashed, my bad - Zax Ftw

1 Answers

2
votes

You can use SUMPRODUCT function for firsts:

=SUMPRODUCT((B9=$B$1:$B$7)*($C$1:$C$7)*(B10=$B$2:$B$8)*($C$2:$C$8<>""))

and for seconds:

=SUMPRODUCT((B9=$B$1:$B$7)*($C$1:$C$7<>"")*(B10=$B$2:$B$8)*($C$2:$C$8))

enter image description here