# Formulae - variable cell reference

#### thunderfoot

##### Board Regular
I have a column of about 600 numbers, say recorded in column 'A' (recorded Odds from a Betting site in 1 second intervals). To one side of this column I want a 'Running Average' based over the last 'x' numbers.

Obviously I can use =AVERAGE(A1:A50) in cell B51 and =AVERAGE(A2:A51) in cell B52 etc. etc by just copying the formulae down column 'B'.

However, I want to experiment and find out "should I use the last 50 numbers or the last 'x' numbers".

To do this I could just change the formulae in column 'B', BUT is there a way to do the following?

In a cell, say C1, enter a number 20, then the AVERAGE formuale would use the last 20 numbers; if I changed the number in cell C1 to 10 then the AVERAGE formulae would use the last 10 numbers etc. etc. thereby somehow using the number entered in cell C1 to determine over how many numbers in column 'A' are used to calculate a 'Running Average'.

### Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

#### Andrew Poulsom

##### MrExcel MVP
In B51 it would be:

=AVERAGE(A51:OFFSET(A51,-C\$1+1,0))

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,164,008
Messages
5,834,860
Members
430,324
Latest member
bosphoruskid

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

### Which adblocker are you using?

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

### Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back