**Please Note: **
This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), *this tip may not work for you*. For a version of this tip written specifically for earlier versions of Excel, click here: Averaging the Last Numbers in a Column.

Emma has a list of numbers in a worksheet (let's say in column A) that are added to on a weekly basis. She needs to calculate the average of the last 12 numbers in the column. She wonders how she can do this and have the average always reflect the last 12 numbers, even when she keeps adding numbers each week.

Assuming that there are no gaps in your range of numbers, you can calculate the average of the last 12 numbers with this formula:

=AVERAGE(OFFSET(A1,COUNTA(A:A)-12,0,12,1))

This formula should, of course, be placed in some cell that is not in column A. It uses the COUNTA function to figure out how many cells contain something in column A. If there are 100 cells in use in column A, this means that you end up with a formula being evaluated in this way:

=AVERAGE(OFFSET(A1,100-12,0,12,1))

Of course, 100 minus 12 is 88, and this number is used as an offset from the starting cell (A2) to say that the range to be averaged should start at A89 and extend down 12 cells. That means that the average ends up being for the range A89:A100. As more numbers are added at the bottom of column A, the formula always reflects the last 12 numbers.

The formula will return an error if column A has fewer than 12 rows worth of data in it. To accommodate that possibility, you may want to alter the formula just a bit:

=AVERAGE(OFFSET(A1,COUNTA(A:A)-MIN(COUNTA(A:A),12),0,MIN(COUNTA(A:A),12),1))

Instead of using a hard-and-fast value of 12 rows, the MIN function (in two places) returns the minimum of either the actual number of rows or 12. So, if your worksheet only has numbers in cells A1:A5, the MIN function would ensure that the formula only averaged those 5 values.

*ExcelTips* is your source for cost-effective Microsoft Excel training.
This tip (10278) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: **Averaging the Last Numbers in a Column**.

**Create Custom Apps with VBA!** Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out *Mastering VBA for Office 2013* today!

Figuring out how to average data that is in a contiguous range of cells is easy. When the data is spread over a group of ...

Discover MoreGrabbing an average of a range of cells is easy using Excel functions. If you want that average to ignore hidden cells when ...

Discover MoreExcel is often used to analyze data collected over time. In doing the analysis, you may want to only look at data collected ...

Discover More**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

Got a version of Excel that uses the
ribbon interface (Excel 2007 or later)?
**This site is for you!** If you
use an earlier version of Excel, visit
our *ExcelTips* site focusing on the menu interface.

**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

Copyright © 2017 Sharon Parq Associates, Inc.

2017-01-08 19:40:54

Peter Atherton

Vasant

Try this

=AVERAGE(OFFSET($A$29,1,0,30))

Regards

Mike

I don't quite understand the column B bit but here is a simple formula

Enter the date you want in G3 in B2 enter =G3-12

and the formula =AVERAGEIFS(C2:C232,A2:A232,">="&G2,A2:A232,"<="&G3)

HTH

2017-01-07 13:59:27

Vasant Bhanushali

if i want the average of 30 cells from a60 upwards. because i keep on adding 1 cell at A30 daily , the formula Average (A30:A60) changes to Average(A31:A61)

I want the formula to remain Average(A30:A60)

how do i do this

2016-10-29 02:59:09

Mike Daley

I am trying to find a formula to work out an average of the previous 12 weeks from any week. So I have a list of weeks with figures in column C and I want the previous 12 weeks average from any particular date, excluding any weeks where column B has a number in. When I exclude this value, I want the next previous week adding so the total averaged will always be 12 weeks. Does anybody have a formula to calculate this?

2016-08-11 11:43:13

Ed

This tip was exactly what I needed. Thank you for providing this formula.

2016-07-26 12:36:23

Michael (Micky) Avidan

@Eamonn,

Assuming the values are in the range A1:A100, try the following formula in cell A2:

--------------------------------

AVERAGE(OFFSET(A1,,100-12,,12))

--------------------------------

Michael (Micky) Avidan

“Microsoft® Answers" - Wiki author & Forums Moderator

“Microsoft®” MVP – Excel (2009-2017)

ISRAEL

2016-07-25 09:31:54

Eamonn

Hi,

how would I do the same as above but only for rows?(Horizontally)

2016-07-13 16:50:36

Saul Tave

I want to average the latest 3 entries in a horizontal line of cells, excluding any cells with no value in them. Example: a group of golfers record their "points" each week that they play to achieve the "average points" they are targeted to achieve next time they play, but they do not all play every week. I want to average the last 3 times each of them played. How can I do this?

2016-04-14 11:59:34

Mani

72 29/05/15 09:21 1,00

i want to calculate only last numbers "1,00". i have more than 8000 lines and i want to calculate.

2016-03-31 09:17:18

Michael (Micky) Avidan

@BMOCK,

Allen's suggested formula is correct.

Assuming you have 20 values in the range A1:A20.

* The part: COUNTA(A:A)-12 returns: 8

* If you move down 8 cells (starting at A1) you end in cell: A9

2) Offset 12 from A9 ends in: A9:A20 which are the last 12 cells in the column.

*** by the way - the [width] argument is optional and, in our case, can be avoided.

*** The Columns offset is: 0 therefore we can omit its typing between the two adjacent commas.

Here is the formula I would use:

=AVERAGE(OFFSET(A1,COUNTA(A:A)-12,,12))

--------------------------

Michael (Micky) Avidan

“Microsoft® Answers" - Wiki author & Forums Moderator

“Microsoft®” MVP – Excel (2009-2016)

ISRAEL

2016-03-30 18:06:33

Pete Hosking

Thanks Allen that was perfect. I needed this for SUM and that worked exactly the same. It was late in the day and my brain was a bit beyond working this out so many thanks.

2015-12-04 17:30:31

BMOCK

To add up the last 12 rows, shouldn't you only offset by 11 rows (-11) and then have the range be 12 rows? Like this? AVERAGE(OFFSET(A1,COUNTA(A:A)-11,0,12,1))

2015-10-11 17:05:13

Peter Atherton

@Andrew

Whoops

The formula should have been:

=SUM(OFFSET($B$1,COUNTA(B:B)-MIN(COUNTA(B:B),12),0,MIN(COUNTA(B:B),12),1))/(13-COUNTIF(B1:B100,"=0"))

2015-10-09 08:44:27

Peter Atherton

Try:

=SUM(OFFSET($A$1,COUNTA(A:A)-MIN(COUNTA(A:A),12),0,MIN(COUNTA(A:A),12),1))/(12-COUNTIF(A1:A100,"=0"))

2015-10-06 14:26:52

Andrew

This tip was very helpful, but I am having one problem. When you put in the 12, it sums the next twelve cells down and takes the average. In my spreadsheet, sometimes the next twelve cells contain a zero. Is there a formula to sum only the next twelve cells that are greater than zero and then take the average?