Search code examples
excelgoogle-sheetsexcel-formulaspreadsheet

How can I create a SUM function in sheets that keeps adding cells?


I have a spreadsheets where I keep the accounting and which contains in a specific row the profit of the products I ship. I'd like to create a sparkline of the money that I win and how it starts to sum up. It does look pretty basic, but the problem is that I do not know how to put the data so as to create the sparkline graphic. To explain it, I have the first product in a specific cell, and two cells below I have the second one and so on and so on. When I create de SUM function for the data I start:

=SUM(J10) =SUM(J10:J12) =SUM(J10:J14) And so on

That's were the problem is, I don't know how to make a formula that will automate this. I wish I could do something like "=SUM(J10:J(10+3 * 'some number')" but it doesn't work. Thanks if anybody takes the time to reply.


Solution

  • There are several approachs.

    If 'some number' is in a cell, the formula is =SUM(OFFSET($J$10,,,L10,1)) (e.g M10)

    To sum column J based on another column, use =SUM(OFFSET($J$10,,,COUNTA(I:I)-1,1)) (e.g M17)

    enter image description here