arrayformula sum in Google spreadsheet

前端 未结 10 2346
野性不改
野性不改 2020-12-14 17:02

How do you arrayformula() a sum() such as:

=sum(A1:H1)

I need to go down 1000 rows.

10条回答
  •  别那么骄傲
    2020-12-14 17:15

    if I look at this formula I really think the following might be simpler. Add this to Tools > Script Editor:

    function row_sum(range_to_sum_per_row) {
      var result_column = [];
      for (var r = 0; r < range_to_sum_per_row.length; r++) {
        var row_sum = parseFloat(0);
        for (var c = 0; c < range_to_sum_per_row[r].length; c++) {
            row_sum += range_to_sum_per_row[r][c] || 0;
        }
        result_column.push([row_sum]);
      }
      return result_column;
    }
    

    use this like so for performance reasons, where C:H is the range you want to sum up and A:A is a column that does not contain an empty string:

    =row_sum(filter(C2:H, len(A2:A)>0))
    

提交回复
热议问题