Google Spreadsheet sum which always ends on the cell above

后端 未结 7 1466
余生分开走
余生分开走 2020-12-24 01:30

How to create a Google Spreadsheet sum() which always ends on the cell above, even when new cells are added? I have several such calculations to make on each single column s

7条回答
  •  半阙折子戏
    2020-12-24 01:52

    NOTE After testing this answer, it will only work if the sum is in a different column due to a circular dependency error. Otherwise, the solution is valid.

    It's a bit of algebra, but we can take advantage of Spreadsheets' lower right corner drag.

    =SUM(X:X) - SUM(X2:X)
    

    Where X is the column you are working with and X2 is your ending point. Drag the formula down and Sheets will increment the X2, thus changing the ending point.

    *You mentioned that you had tens of such calculations to make. So in order to fit your exact need, we would subtract your last summation to get that "middle" range that we wanted.

    e.g.

    B1..B9 should be summed on B10, and B11..B19 should be summed on B20

    Because of the circular dependency error mentioned earlier, I can't solve it exactly and put the sum on the same line, but this could work in other cases where the sum needs to be stored in a different column.

    =SUM(B:B) - SUM(B9:B) //Formula on C10 (Sum of B1..B9)
    =SUM(B:B) - SUM(B19:B) - B10 // Formula on C20 (Sum of B11..B19)
    

提交回复
热议问题