Search code examples
libreoffice-calc

SUM using row range specified on other cells in LibreOffice Calc


Suppose I have the following spreadsheet in LibreOffice calc:

  | A | B | C | D |
-------------------
|1| 1 | 2 |   | 2 |
|2| 2 | 3 |   | 3 |
|3| 6 |10 |   |   |
|4|11 | 2 |   |   |

I want a formula that does a sum =SUM(A1:B4) but using only rows in the range starting with the row number specified in D1 and ending with row number specified in D2. In this example above the result is 21.

The idea would be something like =SUMIF(A1:B4; "AND(ROW()>=D1;ROW()<=D2)") (but is does not work).

What formula can perform this?


Solution

  • =SUM(INDIRECT("A" & D1 & ":B" & D2))
    

    Documentation: INDIRECT