ZetCode

Excel OFFSET Function

last modified April 4, 2025

The OFFSET function is a powerful lookup and reference function in Excel. It returns a reference to a range that is offset from a starting cell or range. This tutorial provides a comprehensive guide to using the OFFSET function with detailed examples. You'll learn basic syntax, practical applications, and advanced techniques to master this versatile Excel function.

OFFSET Function Basics

The OFFSET function returns a reference to a range that is a specified number of rows and columns from a starting reference. It can return a single cell or a multi-cell range. The syntax has required and optional arguments.

Component Description
Function Name OFFSET
Syntax =OFFSET(reference, rows, cols, [height], [width])
Arguments reference (required), rows (required), cols (required), height (optional), width (optional)
Return Value Reference to a cell or range

This table breaks down the essential components of the OFFSET function. It shows the function name, complete syntax format, argument requirements, and return value characteristics.

Basic OFFSET Example

This example demonstrates the simplest use of the OFFSET function to reference a cell offset from a starting point.

A B
Apple
Banana
Cherry
=OFFSET(A1, 2, 0)

The table shows a simple spreadsheet with fruit names in column A. The OFFSET formula in cell B4 references a cell 2 rows below A1 (which would be A3).

Basic OFFSET formula
=OFFSET(A1, 2, 0)

This formula starts at cell A1, moves down 2 rows (to A3), and stays in the same column (0 column offset). The result will be "Cherry". This shows how OFFSET can dynamically reference different cells.

OFFSET with Dynamic Range

OFFSET can create dynamic ranges that adjust automatically when data changes. This example shows how to sum a variable number of values.

A B
100
200
300
=SUM(OFFSET(A1,0,0,3,1))

The table demonstrates using OFFSET to create a range of 3 rows starting at A1. The SUM function then adds all values in this dynamic range.

OFFSET with dynamic range
=SUM(OFFSET(A1,0,0,3,1))

This formula creates a range starting at A1 (0 row and column offset), with a height of 3 rows and width of 1 column. SUM then adds these values (100+200+300) for a result of 600. The range adjusts if the height parameter changes.

OFFSET for Moving Averages

OFFSET is commonly used in financial analysis to calculate moving averages. This example shows a 3-month moving average calculation.

A B C
Month Sales 3-Month Avg
Jan 1200
Feb 1500
Mar 1800 =AVERAGE(OFFSET(B2,0,0,3,1))
Apr 1600 =AVERAGE(OFFSET(B3,0,0,3,1))

The table shows monthly sales data with a column for 3-month moving averages. The OFFSET function creates a dynamic range that moves down as the formula is copied.

OFFSET for moving average
=AVERAGE(OFFSET(B2,0,0,3,1))

This formula calculates the average of a 3-row range starting at B2. When copied down, it calculates each subsequent 3-month period. The result for March would be (1200+1500+1800)/3 = 1500.

OFFSET with MATCH for Dynamic Lookup

Combining OFFSET with MATCH creates powerful dynamic lookup formulas. This example finds a value based on user input.

A B C D
Product Price Search: Banana
Apple 1.20 Result: =OFFSET(A1,MATCH(D1,A2:A4,0),1)
Banana 0.80
Cherry 2.50

The table demonstrates a lookup system where the user can enter a product name in D1, and the formula returns the corresponding price from column B.

OFFSET with MATCH
=OFFSET(A1,MATCH(D1,A2:A4,0),1)

This formula matches "Banana" in D1 with the products in A2:A4, returning position 2. OFFSET then starts at A1, moves down 2 rows, and right 1 column to return 0.80. This creates a flexible lookup system.

OFFSET for Dynamic Chart Ranges

OFFSET can define dynamic chart ranges that automatically adjust as data grows. This example shows how to create a named range for charts.

Dynamic named range with OFFSET
=OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A),1)

This formula creates a range starting at A1, with height equal to the count of non-empty cells in column A. When used as a named range in a chart, the chart automatically updates as new data is added to column A.

OFFSET Limitations and Alternatives

While powerful, OFFSET has some limitations. It's volatile (recalculates with any change) and can make formulas complex. Modern Excel offers alternatives like INDEX and dynamic arrays.

Function Advantage
OFFSET Flexible, can return ranges
INDEX Non-volatile, often more efficient
INDIRECT Can build references from text
Dynamic Arrays Newer, spill functionality

This table compares OFFSET with alternative functions. While OFFSET remains useful, understanding these alternatives helps choose the best tool for each situation.

The OFFSET function is a versatile tool for dynamic referencing in Excel. From simple cell references to complex dynamic ranges, OFFSET provides flexibility in formula creation. While it has some performance considerations, its ability to create adaptable formulas makes it invaluable for many advanced Excel applications.

Author

My name is Jan Bodnar, and I am a passionate programmer with extensive programming experience. I have been writing programming articles since 2007. To date, I have authored over 1,400 articles and 8 e-books. I possess more than ten years of experience in teaching programming.

List all Excel Formulas.