05-30-2020 02:08 PM
05-30-2020 02:08 PM
I'm trying to dynamically put a variable range of cells in an AVERAGE function to cover different periods preceding the most recent. In this approach I would only have to change the last row number (in this case 2820 in C2839) instead of recalculating and changing each AVERAGE formula. I have tried numerous approaches but can't seem to rid the result of quote characters which show up during an Evaluate Formula but don't show in the CONCAT cell itself. It may be something simple I'm overlooking but at this point I could use some help. GRProbA shows the normal view; GRProbB shows the formulas.
05-30-2020 02:37 PM - edited 05-30-2020 02:42 PM
Hello @Lucky7423 ,
You cannot just create a text string and use that like a range reference. You need to convert the text to a range with the Indirect function. So, if cell E2 contains a formula that returns "A1:A4" as a text, then you can use
Or you can build the concatenation right into the Indirect function
Screenshot to illustrate:
05-30-2020 02:42 PM - edited 05-30-2020 02:43 PM
another approach is to use Offset() instead of Indirect() to create a variable range. The syntax for Offset is
Offset(A1,0,0,4) will generate a range that starts at A1, goes 0 rows down, 0 columns to the right (i.e. it anchors at A1), is 4 rows high and, since no width is specified, has the same width as the first parameter (A1, so 1 column wide).
Change the first parameter to modify the start date and change the height parameter to return more rows.
05-31-2020 01:35 AM
Just to add to @Ingeborg Hawighorst's posts, it should be pointed out that volatile INDIRECT and OFFSET set-ups can almost always be replaced with a non-volatile INDEX one in such cases.
For example, the following are all equivalent:
though only the first is non-volatile (well, not quite: technically volatile just once, i.e. when the workbook is first opened, but for all intents and purposes that's non-volatile).
05-31-2020 07:14 AM
@Jos_Woolley Thank you for responding. Seeing your three examples together is helpful.
05-31-2020 07:18 AM
One more point - it looks like you calculate the same range sizes. They could be defined in any helper range, e.g.
And if in A1 the last row to use, e.g. 2820, formula for 7 days average could be, as suggested earlier,
and drag it down to receive another 4 averages.