Home > OS >  Google Sheets: how to sum a dynamic range across columns using a variable to determine range length
Google Sheets: how to sum a dynamic range across columns using a variable to determine range length

Time:12-02

I'm trying to write a formula in Google Sheets that will enable me to sum a range of values across columns, where I can manipulate the number of cells to be summed across the column with a variable. For example:

  • if my variable is 5, then I want to sum(D3:H3);
  • and if my variable is 9, then I want to sum(D3:L3)

Furthermore, I want a formula that I can drag across columns so that the range it's summing moves relative to the cell the formula is in. In the example above with the variable=5:

  • the formula in cell A3 would be sum(D3:H3);
  • and the formula in cell B3 would be sum(E3:I3)
  • etc.

I created a enter image description here

  • Related