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

by Allen Wyatt
(last updated February 12, 2020)

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

Correctly Saving Delimited Files

Delimited files are often created through Excel so that your data can be exported to other programs. If the delimited ...

Discover More

Making VLOOKUP Case Sensitive

The VLOOKUP function, like other lookup functions in Excel, is not case sensitive. In other words, it doesn't matter ...

Discover More

Ignoring Empty Cells in a Chart

If the data you are using as the source for a chart includes some cells that are empty, you may want to exclude those ...

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

Determining a Simple Moving Average

A moving average can be a great way to analyze a series of data points that you've collected over time. Setting up a ...

Discover More

Averaging a Non-Contiguous Range

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 More
Subscribe

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

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. 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 seven minus 4?

2020-10-25 20:44:49

Peter Atherton

Ryan
I made a mistake in the last post. The sum of the last 12 should refer to the address in F9.
Last 12 =SUM(INDIRECT(F9)). Unless you prefer to use the address formula directly
Last 12 =Sum(Indirect("B"&Ptr-11&":B"&Ptr))

2020-10-24 10:33:44

Peter Atherton

Ryan
You can create a range name to get the last row generally using column A. Ctrl = F3, New, Name = Ptr, Refers To = =COUNTA(Sheet6!\$B\$14:\$B\$655536)+13

My Test data starts at Row 14 in column B. To find the sum of all data use
=SUM(INDIRECT("\$B\$14:\$B"&Ptr-13))

To get the address of the last 12 I entered this formula in F9
="B"&Ptr-11&":B"&Ptr

The sum of the last 12 items is
=SUM(INDIRECT("B14:b"&Ptr-13))

(see Figure 1 below)

Figure 1.

2020-10-23 16:03:16

Ryan

I'm having trouble with this process. My data starts in row 20 with other information in the rows & columns above. When I use the equation =OFFSET(G20,COUNT(G20:G65536),0,-200,1), The returned values include 11 cells above G20 that are not numeric. I believe the issues is that there are some non numeric (-'s) in the column of data. How can I resolve this issue to not include any values above G20 even if there are blanks or non numeric values.

2020-02-14 02:18:39

HARISH GUPTA M.R

Hi,
Another way i found we can get average of last 12 numbers is by the below formula,
=AVERAGE(INDIRECT("A"&COUNTA(A:A)-11&":A"&COUNTA(A:A)))
Regards,
Harish

2018-06-13 23:44:08

Hayley

The column for which I am trying to find the avareage of the last four entered values has 0’s in the cells below the most current mileage for that week, as the the information auto populates on a weekly basis according to what is placed in another column. By using the above formula it is returning as 0, but I would like it to return the average of the last 4 cells with a numerical value greater than 0. How can the above formula be modified to do this? Thanks.

2017-09-10 17:45:51

Michael

I have been trying to figure out how to apply the tip above to my situation.

I have a list of data that I enter sales each day. I have a column B that list the days of the week. Column I has the amount. I then get the average sales for Monday using this formula. I created one for each day of the week.

If I want to know the average sales for Mondays for only the last 8 Mondays, of the last 2 months of business, 60 days total, how would I adjust this formula to make it wok.

=AVERAGEIF(\$B\$2:\$B\$366,"Mon",\$I\$2:\$I\$366)

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?

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.

Subscribe

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