Google spreadsheet formula which takes its cell range values from other cell?
Asked Answered
H

2

10

I have a simple formula in A1 cell =sum(A2:A10). Now in a B1 position lets say I put A15 and I would like it to modify a formula in cell A1 to be like this: =sum(A2:A15). So basicly I would like to be able to write a formula like: =sum(A2:A(B1)) which ofcourse does not work but you get what I mean. Apreciate any help with this problem. Thanks.

Hibben answered 26/11, 2014 at 23:16 Comment(0)
V
15

You can use the function INDIRECT (functions overview).

In you case you would place in your A1 cell this formula:

=sum(indirect(CONCAT("A2:A";B1)))

Indirect takes text and turns this into a reference of a cell or range. furthermore CONCAT is used to make the text reference.

Voigt answered 26/11, 2014 at 23:22 Comment(0)
A
3

Just a note - if the value in B1 position is 15 then the response by user254948 is correct. If however the value in B1 position is A15 (as proposed in the original post), the corrected formula would be:

=sum(indirect(CONCAT("A2:",B1)))
Apulia answered 5/5, 2021 at 20:56 Comment(1)
Demo: web.archive.org/web/20230831184452/https://i.imgur.com/…Irruption

© 2022 - 2024 — McMap. All rights reserved.