Grab our practice workbook 👉 HERE and follow along.
The OFFSET function in Excel lets you find a cell or range of cells by moving a certain number of rows and columns from a starting cell. This is very useful for creating dynamic ranges and calculations that can change automatically as your data changes.
Think of OFFSET Excel as a GPS:
You give it a starting point and then you tell it:
- how many rows to go down
- how many columns to move across
- and what range you want returned
Like this:
Syntax of the OFFSET Function
=OFFSET(reference, rows, cols, [height], [width])
- reference: The starting point (a cell or range of cells).
- rows: The number of rows to move from the starting point.
- cols: The number of columns to move from the starting point.
- height: (Optional) The number of rows to return.
- width: (Optional) The number of columns to return.
Simple Example OFFSET Excel
Let’s say we have data in cells A1 to A5. We want to get the value in cell A3 using the Excel OFFSET function.
=OFFSET(A1, 2, 0)
Explanation:
- A1 is the starting point.
- The formula moves down 2 rows from A1 (to A3).
- It doesn’t move any columns to the left or right (0 columns).
So, the formula returns the value in cell A3, which is 30.
Featured Course
Master NEW Excel Functions in Office 365 & Office 2021
Ready to supercharge your Excel skills? This course will help you master the new set of functions introduced to Excel for Office 365. You’ll create professional-grade reports in a fraction of the time it used to take you.
Learn More
Creating Dynamic Ranges
Dynamic ranges adjust automatically as you add or remove data. Here’s how to create a dynamic range for calculating the average of the last six months of sales data.
Imagine you have a table with months in column A and sales revenue in column B.
To get the average of the last six months, follow these steps:
- Starting Point: Use cell B3 as your reference (header of the Sales column).
- Rows to Move: Use the COUNTA function to count the number of filled cells below B3.
- Height: Use -6 to move backward and select the last six cells.
Formula:
=AVERAGE(OFFSET(B3, COUNTA(B4:B15), 0, -6, 1))
Explanation:
- B3: Starting point.
- COUNTA(B4): Counts filled cells below B3.
- 0: Stays in the same column.
- -6: Selects the last six cells.
- 1: Width is 1 column.
This formula calculates the average of the last six months dynamically. If new data is added, the formula automatically updates to include the latest six months.
Using the OFFSET Function with Horizontal Data
Let’s look at an example where data is arranged horizontally. This time, we will use the OFFSET function to calculate the average of the last six months’ sales.
Imagine you have sales data for each month from January to July in cells B17 to H17.
Step-by-Step Instructions
- Starting Point: Use cell A17 as your reference point.
- No Row Movement: Set the row parameter to 0 to stay on the same row.
- Count Columns: Use the COUNT function to count the number of filled cells from columns B to O.
- Height: Set to 1 since we are referencing only one row.
- Width: Set to -6 to select the last six columns.
Formula
=AVERAGE(OFFSET(A17, 0, COUNT(B17:O17), 1, -6))
Explanation:
- A17: Starting point.
- 0: No row movement.
- COUNT(B17): Counts the number of filled cells from B17 to O17.
- 1: Height is 1 row.
- -6: Width is -6 columns (moving backward to get the last six months).
This formula calculates the average of the last six months dynamically. If you add data for August, the formula automatically updates to include August and calculate the new average.
Using OFFSET with Other Functions
The OFFSET function can be combined with other functions to create dynamic moving average calculations. This allows you to select a month and automatically get the average of the next three months.
Example: Dynamic Moving Average Calculation
Imagine you have monthly sales data in column A. You want to calculate the average sales for the three months following the selected month in the drop down in cell E25.
Step-by-Step Instructions:
- Starting Point: Use cell B25 as your reference point (header of the Sales column).
- Finding the Selected Month: Use the MATCH function to find the row number of the selected month from the drop-down list.
MATCH Function:
=MATCH(E25, A26:A51, 0)
- E25: The cell with the selected month.
- A26: The range of months in your data.
- 0: Exact match.
For example, if the selected month is April 2024, and it is the fourth item in the list, MATCH returns 4.
- Using OFFSET with MATCH: Combine OFFSET and MATCH to move to the selected month and average the next three months.
Formula
=AVERAGE(OFFSET(B25, MATCH(E25, A26:A51, 0), 0, 3, 1))
Explanation
- B25: Starting point.
- MATCH(E25, A26, 0): Finds the row of the selected month.
- 0: No column movement.
- 3: Height is 3 rows (next three months).
- 1: Width is 1 column.
This formula calculates the average of the selected month and the next two months.
If you want to exclude the selected month from the average, add 1 to the MATCH result:
=AVERAGE(OFFSET(B25, MATCH(E25, A26:A51, 0) + 1, 0, 3, 1))
Practical Applications of Excel OFFSET
- Tracking Inventory: Use OFFSET to create a dynamic range that updates as you add or remove items in your inventory list.
- Managing Budgets: Create dynamic financial models where income and expense data can be updated regularly without altering core formulas.
- Analyzing Trends: Combine OFFSET with functions like AVERAGE or SUM to analyze data trends over time dynamically.
Tips for Using OFFSET
- Volatile Function: OFFSET recalculates whenever any change is made in the workbook, which can slow down large spreadsheets. Use it wisely.
- Combine with Named Ranges: For better readability and management, combine OFFSET with named ranges.
Common Errors
- #REF! Error: Occurs if OFFSET references a range outside the worksheet. Ensure your reference and offset values are within the worksheet’s bounds.
- Performance Issues: Using OFFSET in large datasets can slow down Excel. Consider using INDEX and MATCH for better performance.
Download the Workbook
Enhance your learning experience by downloading our workbook. Practice the techniques discussed in real-time and master the Excel OFFSET Function with hands-on examples. Download the workbook here and start applying what you’ve learned directly in Excel.
Featured Course
Black Belt Excel Package
What would your life look like if you became an Excel Black Belt?You’ll get the best deal with this (cost savings) package. It will take you from Excel Newbie to Grand Master.
Learn More
Published on: January 17, 2017
Last modified: June 6, 2024
Category: Excel,Formulas
Tagged as: AVERAGE, COUNT, COUNTA, MATCH function, OFFSET
Leila Gharani
I'm a 6x Microsoft MVP with over 15 years of experience implementing and professionals on Management Information Systems of different sizes and nature.
My background is Masters in Economics, Economist, Consultant, Oracle HFM Accounting Systems Expert, SAP BW Project Manager. My passion is teaching, experimenting and sharing. I am also addicted to learning and enjoy taking online courses on a variety of topics.
More About Leila Join 400,000+ professionals in our courses