Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. 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

Written by Allen Wyatt (last updated July 10, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


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, 2013, 2016, 2019, and Excel in Microsoft 365. 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

Entering Many Items In a Drop-Down Form Field

One of the controls you can add to a Word form is a drop-down form field. This field is similar to drop-down lists used ...

Discover More

Using the Equation Editor for Fractions

How to use the Equation Editor when creating formulae in Word documents.

Discover More

Counting Fields in a Document

Need to count the number of times a particular field appears in a document? It's easy to do when you apply the techniques ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

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 ...

Discover More

An Average that Excludes Zero Values

Excel allows you to use functions and formulas to analyze your data. One way you can analyze your data is to use the ...

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 ...

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

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}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. 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 nine minus 5?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

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.

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.