I have one row that uses =MEAN(A1:A15)
, and another one that uses =SUM(A1:A15)
. But many times I have to alter this range to, let's say, A1:A13;A15
in both cells. I would like to alter the range in one place and have both formulas to use the same updated range.
2 Answers
What you can do is use the INDIRECT
formula along with another cell where you specify your range. The INDIRECT
formula allows you to return a cell reference or range based on a text string. For example, you can set a cell equal to =INDIRECT("A2")
and it will show the value of cell A2.
As for how this pertains to your question, if for example we place the text string A1:A15
in cell B1
, you can then get the sum of that range with this formula:
=SUM(INDIRECT(B1))
. Modifying the range in cell B1
will then modify the computed sum accordingly, and you can also perform other formulas with that, like =MEAN(INDIRECT(B1))
.
-
Now I realized I need the inverse function too. Is there any
STRINGIFY(A1:A15)
which would return"A1:A15"
? Jul 28, 2011 at 13:54 -
1You can set a cell equal to
="A1:A15"
if you'd like. You can also use the&
operator to join strings, so if for example if you wanted to return the range of all entries in the A column, you could make the string as="A1:A" & COUNTA(A:A)
. Note that you could also just place that right as the argument of theINDIRECT
formula, instead of referencing another cell. Jul 28, 2011 at 13:56 -
-
You can use a named range to do this, and it's really the recommended way. That is where you give a name to a range of cells, and then you use that name in any formulas. You can later go back and update the range of cells that the name applies to. (You can also do more sophisticated things like having the range automatically adjust in size when you add rows at the end.)
Creating and applying named ranges is under Formula > Named Cells > Name a Range.
More details in this tutorial: http://www.homeandlearn.co.uk/excel2007/excel2007s7p6.html