Excel XLOOKUP with Named Ranges: How-To Guide
In this article
Using XLOOKUP with a named range makes your formulas easier to read and maintain: you define a name for a cell range (for example, ProductList), then use that name in XLOOKUP instead of typing absolute references like $A$2:$A$100. The result is a formula such as =XLOOKUP(A2, ProductList, PriceList) that still works if rows are inserted or the range moves. You need Excel 365, Excel 2021, or Excel for the web (XLOOKUP is not in Excel 2019 or earlier), plus a table of data with a unique lookup column and a return column.
What You'll Need
- Excel 365, Excel 2021, or Excel for the web (XLOOKUP is unavailable in older perpetual versions).
- A worksheet with your lookup values in one column and the values you want to return in another column on the same sheet or a different sheet.
- Basic familiarity with selecting cells and typing formulas.
Step-by-Step
- Set up your data. Put your lookup values (e.g., product codes) in one column and the values you want to return (e.g., prices) in an adjacent column. Ensure the lookup column has no duplicates; XLOOKUP returns the first match only.
- Select the lookup range. Highlight the cells containing the lookup values, such as
A2:A100. Do not include the header row. - Create a named range. Go to the Formulas tab and click Define Name (or press Ctrl+F3 to open Name Manager, then click New). In the New Name dialog, type a name like
ProductListin the Name box. Names cannot contain spaces; use underscores or camel case. Leave Scope as Workbook unless you need a sheet-specific name. In Refers to, confirm the range (e.g.,=Sheet1!$A$2:$A$100). Click OK. - Repeat for the return range. Select the cells with the values to return (e.g.,
B2:B100), then Formulas > Define Name. Name itPriceListand confirm the reference. Click OK. - Write the XLOOKUP formula. Click the cell where you want the result. Type
=XLOOKUP(, then select the cell containing the value you want to look up (e.g.,A2), type a comma, then type the first named range (ProductList), a comma, and the second named range (PriceList), then close the parenthesis. The formula should look like=XLOOKUP(A2, ProductList, PriceList). Press Enter. - Check the result. The formula should return the matching value from the return range. If it returns
#N/A, the lookup value was not found; if it returns#NAME?, a name is misspelled or not defined. - Copy the formula down. Drag the fill handle or copy and paste the formula to other rows. Because you used named ranges, the references stay fixed even if you insert rows inside the named range.
- Optional: add if_not_found. XLOOKUP's fourth argument lets you specify what to return when no match is found. For example,
=XLOOKUP(A2, ProductList, PriceList, "Not found").
Common Mistakes
- Including the header row in the named range. XLOOKUP will try to match against the header text, causing mismatches. Always start the range at the first data row.
- Using spaces in the name. Excel rejects names with spaces. Use underscores (e.g.,
Product_List). - Forgetting to update the named range when adding data. If you add rows below the original range, the name won't automatically expand unless you used a table (ListObject) or a dynamic formula. Either edit the name's Refers to box or convert your data to an Excel Table and use structured references instead.
- Mismatched range sizes. The lookup range and return range must have the same number of rows. If they differ, XLOOKUP returns
#VALUE!. - Typing the name with a typo. Excel will show
#NAME?. Check the spelling in Name Manager.
Tips
- Use the Name Box (left of the formula bar) to quickly create a name: select the range, type the name in the Name Box, and press Enter.
- Press F3 while typing a formula to open the Paste Name dialog and insert a named range without typing.
- Named ranges work across sheets. If your data is on another sheet, the name still refers to the correct cells.
- For dynamic ranges that grow automatically, convert your data to an Excel Table (Insert > Table) and use structured references like instead of named ranges.
- Keep names descriptive but short, e.g.,
ProdIDandProdPrice.
Troubleshooting
If XLOOKUP returns #NAME?, the named range is misspelled or not defined. Open Name Manager (Formulas > Name Manager) and verify the name exists and is spelled exactly as in the formula. If it returns #N/A, the lookup value is not present in the lookup range; check for extra spaces or case differences (XLOOKUP is not case-sensitive by default, but trailing spaces matter). If it returns #VALUE!, the two ranges likely have different row counts; edit the names to match. If the formula returns an unexpected value, confirm the return range is aligned with the lookup range (same starting row). If you inserted rows and the named range didn't expand, update the Refers to box in Name Manager or switch to a Table. If XLOOKUP is not available, you are likely using an older Excel version; consider using INDEX/MATCH with named ranges as an alternative.
Frequently Asked Questions
Can I use a named range for the lookup value itself?
Yes, but it's less common. The lookup value is usually a single cell. If you name a single cell (e.g., SearchKey), you can write =XLOOKUP(SearchKey, ProductList, PriceList).
Do named ranges work with XLOOKUP across different workbooks?
Yes, if both workbooks are open. The name must be defined in the workbook where the formula resides, and the reference must point to the external workbook. However, this can be fragile; it's often better to keep data in one workbook.
What happens if I rename a named range?
Excel automatically updates all formulas that use the old name, provided the name is used directly in formulas (not inside text strings).
Can I use XLOOKUP with a named range that refers to a whole column?
Yes, but it may be slower on large datasets. For example, =XLOOKUP(A2, ProductList, PriceList) where ProductList refers to $A:$A works, but it's better to limit to the used range.
Is XLOOKUP case-sensitive?
No, by default XLOOKUP is not case-sensitive. To make it case-sensitive, you would need to use a different approach, such as combining XLOOKUP with EXACT, but that's beyond this guide.
Why does my named range not appear in the Formula AutoComplete?
Ensure the name is defined at the workbook level (not sheet level) and that you are typing in a cell, not in the Name Box. Also, check that the name doesn't conflict with a cell reference (e.g., ABC1).