Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 5 down vote accepted

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)).

share|improve this answer
Now I realized I need the inverse function too. Is there any STRINGIFY(A1:A15) which would return "A1:A15"? – Jader Dias Jul 28 '11 at 13:54
You 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 the INDIRECT formula, instead of referencing another cell. – Breakthrough Jul 28 '11 at 13:56
Thanks, but I mean… – Jader Dias Jul 28 '11 at 14:05
@Jader Dias also posted an answer there for you. – Breakthrough Jul 28 '11 at 14:52

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:

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .