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.

Averaging the Last Numbers in a Column

by Allen Wyatt
(last updated August 3, 2015)

14

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.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Turning Off Names

You can use some of the tools in Excel to convert cell references in formulas into names. Converting back (from names into ...

Discover More

Shortcut for AutoCorrect Dialog Box

There is no built-in keyboard shortcut that will display the AutoCorrect dialog box. This doesn't mean that there aren't a ...

Discover More

Word Count is Zero

If you use the Word Count tool and are surprised that it returns a count of 0, it could be because of what you selected prior ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

MORE EXCELTIPS (RIBBON)

Averaging Values for a Given Month and Year

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

Discover More

Excluding Values from Averaging

Calculating 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

Averaging without Hidden Cells

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

Discover More
Subscribe

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

View most recent newsletter.

Comments for this tip:

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is seven minus 6?

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?


Newest Tips
Subscribe

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

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.

Links and Sharing
Share