Hi Dan,
The Input box prompts for the number of iterations. Your original example used four, but in the real world rather than prompt for a number you'd may be able to use a system variable which identifies the number of iterations from a list of values.
I left the first formula as the RC notation since I didn't seem to fit in with the rest of the example. I generally prefer to use the A1 notation, hence the rest of the code.
The two columns you're using (B & C) are hard coded but again for a generalised solution you may be able to generate those with variables which work out the columns to use.
The x variable is a loop counter and is set by the answer to the input box. In your example the various ranges that you're averaging are 9 rows apart, hence the hard coded reference to '9' in the Excel formula. So for instance in the first iteration where x = 1, the code
multiples 1 by 9 and adds 33 to set the start of the range to row 42, and the end of the range to 1 x 9 plus 37, i.e. 46. The column is hard codes as "I"
On the second iteration, x =2 and hence 2 x 9 + 33 = 51 which is the start of the second range.
etc...
Bookmarks