**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!

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

Discover MoreFiguring 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 MoreCalculating an average of a group of numbers is easy. What if you want to exclude a couple of the numbers from the group you ...

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

2017-01-08 19:40:54

Peter Atherton

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

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

how do i do this

2016-10-29 02:59:09

Mike Daley

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

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

2016-04-14 11:59:34

Mani

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

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

2015-12-04 17:30:31

BMOCK

2015-10-11 17:05:13

Peter Atherton

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

=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

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.

## Comments