OFFSET returns a range that’s shifted and resized from a starting point — perfect for a moving window like “the last 3 months” that follows your data as it grows. Combine it with COUNT to always grab the most recent N values.
E1 rows tall reaching back up — the last N values.
The example
Summing the last 3 months, which follows the data downward.
| A | B | |
|---|---|---|
| 1 | Month | Sales |
| 2 | Jan | $100 |
| 3 | Feb | $140 |
| 4 | Mar | $120 |
| 5 | Apr | $180 |
| 6 | May | $150 |
| 7 | Last 3 total: | $450 |
The formula
Sum of the last 3 months:
How it works
OFFSET defines the window; COUNT finds the bottom:
COUNT(B2:B100)counts the data rows — so OFFSET knows where the bottom of the list is.OFFSET(B1, thatCount, 0, -3, 1)starts at B1, moves down to the last value, then takes a block 3 rows tall (the-3reaches upward) and 1 column wide.- That block is the last 3 values;
SUMtotals them. - Add a new month and the window slides automatically — it always covers the most recent 3.
OFFSET is the classic dynamic-range engine — for moving averages, expanding charts, and self-resizing named ranges. In Excel 365, INDEX or the spill # operator often replace it with non-volatile alternatives.
Try it: interactive demo
Sum the last N of {100,140,120,180,150}.
Variations
Average the last N (moving average)
Swap SUM for AVERAGE:
Non-volatile with INDEX
A faster alternative for the last N:
A self-resizing named range
Name a range as =OFFSET($B$2,0,0,COUNTA($B:$B)-1,1) for charts.
Pitfalls & errors
OFFSET is volatile. It recalculates on every change. For large models, the INDEX-based alternatives are faster.
#REF! if the window runs off the sheet. Asking for more rows than exist pushes OFFSET out of bounds. Cap N at the data count.
COUNT ignores text. If your column mixes text and numbers, use COUNTA for the row count so the bottom is found correctly.
Practice workbook
Frequently asked questions
How do I sum the last N rows in Excel?
How do I make a moving average of recent values?
Is there a non-volatile alternative to OFFSET?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class