OFFSET vs XLOOKUP: Which Excel Function to Use
In this article
Use XLOOKUP when you need to find a value by a key and return a corresponding result from another column or row; use OFFSET only when you need to build a dynamic range that moves or resizes based on a reference. XLOOKUP is the modern, safer choice for lookups because it is non-volatile, handles errors natively, and works left-to-right or right-to-left without restructuring your data. OFFSET is a reference function that returns a range, not a value, and it recalculates on every sheet change, which can slow large workbooks. This guide shows when and how to use each, with practical examples.
What You'll Need
- Microsoft Excel 365, Excel 2021, or Excel 2024 for XLOOKUP (XLOOKUP is not available in Excel 2019 or earlier).
- Any version of Excel that supports OFFSET (all modern versions do).
- A table of data with a clear key column (e.g., product ID, employee name) and a return column.
- Basic familiarity with cell references and named ranges.
Step-by-Step
- Decide your goal. If you need to retrieve a single value based on a lookup key (e.g., find the price for a product ID), use XLOOKUP. If you need a range that shifts position or size based on a count or user input (e.g., sum the last 10 rows of a growing list), use OFFSET.
- For XLOOKUP: set up your data. Ensure your lookup column and return column are in the same table or contiguous range. XLOOKUP does not require the lookup column to be leftmost, unlike VLOOKUP.
- Write the XLOOKUP formula. The syntax is
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode]). For example, to find the price of product ID in A2 from a table where IDs are in D2:D100 and prices in E2:E100:=XLOOKUP(A2, D2:D100, E2:E100, "Not found"). The fourth argument replaces #N/A with a friendly message. - For OFFSET: define your starting reference. The syntax is
=OFFSET(reference, rows, cols, [height], [width]). For example, to create a range that starts 2 rows below A1 and is 5 rows tall and 3 columns wide:=OFFSET(A1, 2, 0, 5, 3). - Use OFFSET with a dynamic count. To sum the last 10 values in column A (assuming data starts at A2 and grows downward), use:
=SUM(OFFSET(A2, COUNT(A:A)-10, 0, 10, 1)). This adjusts as rows are added. - Test both formulas. Change a lookup value or add rows to your data to confirm XLOOKUP returns the correct result and OFFSET expands or shifts as intended. If XLOOKUP returns #NAME?, your Excel version does not support it.
- Convert OFFSET to a non-volatile alternative where possible. For dynamic ranges, use Excel Tables (Ctrl+T) and structured references, or INDEX with COUNTA, which recalculate only when data changes, not on every edit.
Common Mistakes
- Using OFFSET for simple lookups: OFFSET returns a reference, not a value, so you must wrap it in a function like SUM or INDIRECT to get a result. XLOOKUP returns the value directly.
- Forgetting that OFFSET is volatile: every change to the workbook forces OFFSET to recalculate, which can slow down large models. XLOOKUP is non-volatile.
- Mismatched array sizes in XLOOKUP: the lookup_array and return_array must be the same size, or you get a #VALUE! error.
- Hardcoding row/column offsets in OFFSET: if rows are inserted or deleted above the reference, the offset may point to the wrong data. Use COUNT or MATCH to make it dynamic.
- Assuming XLOOKUP works in older Excel: it is only in Excel 365, 2021, and 2024. In Excel 2019 or earlier, use INDEX/MATCH instead.
Tips
- Use XLOOKUP's
if_not_foundargument to avoid ugly #N/A errors in reports. - XLOOKUP can search from the bottom up by setting
search_modeto -1, useful for finding the last occurrence. - For dynamic ranges, prefer Excel Tables over OFFSET. Tables auto-expand and are non-volatile.
- If you must use OFFSET, keep the reference close to the data and avoid whole-column references like OFFSET(A:A, ...), which can be very slow.
- Combine XLOOKUP with IFERROR for cleaner error handling in older versions that lack the
if_not_foundargument (though XLOOKUP itself has it).
Troubleshooting
- XLOOKUP returns #NAME?: Your Excel version does not support XLOOKUP. Use INDEX/MATCH:
=INDEX(E2:E100, MATCH(A2, D2:D100, 0)). - XLOOKUP returns #VALUE!: Check that lookup_array and return_array have the same number of rows or columns. They must be congruent.
- OFFSET returns #REF!: The offset moves the reference outside the worksheet. Reduce the rows/cols arguments or check your reference cell.
- OFFSET gives wrong results after inserting rows: The reference may have shifted. Use a fixed reference like
$A$1or switch to a Table. - Workbook is slow with OFFSET: Replace OFFSET with INDEX or direct references. If you need dynamic ranges, use Tables or dynamic array formulas.
Frequently Asked Questions
Can I use XLOOKUP instead of OFFSET for dynamic ranges?
No. XLOOKUP returns a value or array of values, not a reference. For dynamic ranges, use OFFSET, INDEX, or Excel Tables. XLOOKUP can return a spilled array if the return_array is multiple columns, but it does not create a movable reference.
Is OFFSET volatile and why does it matter?
Yes, OFFSET is a volatile function, meaning it recalculates every time the worksheet recalculates, even if its inputs haven't changed. This can slow down large workbooks. XLOOKUP is non-volatile and only recalculates when its inputs change.
Which Excel versions support XLOOKUP?
XLOOKUP is available in Excel for Microsoft 365, Excel 2021, and Excel 2024. It is not available in Excel 2019 or earlier. For older versions, use INDEX/MATCH or VLOOKUP.
Can XLOOKUP search to the left?
Yes. Unlike VLOOKUP, XLOOKUP can look in any column and return a value from any other column, including to the left of the lookup column. Just specify the correct lookup_array and return_array.
What is the difference between OFFSET and INDEX?
Both return references, but INDEX is non-volatile and generally faster. OFFSET is more flexible for creating ranges that move by a specified number of rows and columns, but INDEX is preferred for simple lookups or when performance matters.
Can I use OFFSET to create a dynamic named range?
Yes, you can define a named range using OFFSET with COUNTA to expand automatically. However, because OFFSET is volatile, consider using a Table or INDEX with COUNTA for better performance.