1
votes

I'm trying to write a formula to add the contents of a column in cell D5, so normally I would write =SUM(D2:D4). However, the location of the formula cell (currently D5) will change as I add more rows. How do I write a formula that accounts for this?

(The formula I want would hypothetically look something like =SUM(D2:CellAboveCurrentCell).)

Thank you!

2

2 Answers

2
votes

Try this formula:
=Sum(D2:INDIRECT(ADDRESS(ROW()-1,COLUMN())))

See this post for a more detailed explanation.

1
votes

You can use INDEX function:

=SUM(D2:INDEX(D:D;ROW()-1;1))

enter image description here