Home > Back-end >  How to reference an adjacent cell in google sheets relative to the selected cell
How to reference an adjacent cell in google sheets relative to the selected cell

Time:07-26

I am trying to use the =sum() function in google sheets, and so far, that's all I have typed into the targeted cell. For example, I want D3 to be the sum of C2 and D2. I know how to type that. =sum(C2,D2). But I want cells D3 thru D30 to have the same equation, relative to their adjacent cells. Something like this =sum(cell to the left, cell above). Let me know if you need more elaboration, or if you have the answer, great!

CodePudding user response:

Solution

Paste this formula in the first cell next to your numbers or take a look at the enter image description here

Explanation

  • We check the above cell ISNUMBER if so we calculate C2 D1 if not we put 0

  • IF(C2="",, to calculate onlt when the range C2:C is not Empty.

CodePudding user response:

If you are looking for a single formula you can also try

=INDEX(IF(ISNUMBER(C2:C), SUMIF(ROW(C2:C),"<="&ROW(C2:C),C2:C),))

enter image description here

  • Related