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.