View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Coderre Ron Coderre is offline
external usenet poster
 
Posts: 698
Default XL how to change a cell reference in a formula to variable val

Drat! Typo!

This part:
If B1 is 101 and B2 is 5

should be this
If B1 is 11 and B2 is 5

(I'm torn between blaming my fingers for typing it or my eyes for not
catching it)

***********
Regards,
Ron

XL2002, WinXP


"Ron Coderre" wrote:

Try something like this:

=AVERAGE(A1:INDEX(A:A,B1))

Whe
B1 contains the number of cells to include in the average.

Alternatively,
you could indicate the start cell and the number of cells to include with
this:
=AVERAGE(INDEX(A:A,B1):INDEX(A:A,B1+B2-1))

Whe
B1 contains the starting cell row number
B2 contains the number of cells to include in the average

For example
If B1 is 101 and B2 is 5
The formula would calculate the average of cells A11:A15

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"Bernard" wrote:

I want to change a cell range in a formula to be a variable reference. This
is to allow calculation of a moving average which is selectable. Example
change the moving average from calculation over 10 values (A1:A10) to
calculation over 50 values (A1:A50), without having to go in and change the
formula. In this example the variable value would be 10 to 50 (in say B1).
any ideas?