Excel XLOOKUP Lock Reference Cell: Step-by-Step Guide
In this article
To lock a reference cell in an XLOOKUP formula, add dollar signs to the lookup value, lookup array, or return array before you copy the formula. For example, =XLOOKUP($A2,Sheet2!$A$2:$A$100,Sheet2!$B$2:$B$100) locks the lookup value to column A while letting the row change, and locks the lookup and return arrays to absolute ranges. This keeps the formula pointing at the right cells when you fill it down or across.
XLOOKUP is available in Excel for Microsoft 365, Excel 2021, and Excel for the web. The steps below work on Windows and Mac desktop; the web version supports the same function but the ribbon layout may differ slightly. Menu and dialog labels can vary a little by version and region.
What You'll Need
- Excel for Microsoft 365, Excel 2021, or Excel for the web (XLOOKUP is not in Excel 2019 or earlier).
- A source table with a unique lookup column and at least one return column.
- Basic familiarity with cell references and the difference between relative (A1) and absolute ($A$1) references.
Step-by-Step
- Set up your source data as an Excel Table (recommended). Select any cell in your source range and press Ctrl+T (Windows) or Cmd+T (Mac). Confirm the range and that “My table has headers” is ticked. Give the table a name in Table Design > Table Name, for example
tblProducts. Using a table means XLOOKUP can reference structured columns liketblProducts[SKU]andtblProducts[Price], which expand automatically when you add rows. - Decide what needs locking. The lookup value (the cell you type the search term into) usually needs its column locked so you can drag the formula across, e.g.
$A2. The lookup array and return array must be locked so they never shift, e.g.$A$2:$A$100and$B$2:$B$100, or the structured references above. - Write the formula with absolute references. Click the cell where you want the result and type:
=XLOOKUP($A2,$D$2:$D$100,$E$2:$E$100)
Here$A2locks the lookup value to column A,$D$2:$D$100is the locked lookup array, and$E$2:$E$100is the locked return array. If you are using a table, type=XLOOKUP($A2,tblProducts[SKU],tblProducts[Price])instead — structured references are already anchored to the table. - Use F4 to add dollar signs quickly. While editing the formula, select the reference you want to lock (for example
D2:D100) and press F4. Excel cycles through relative, absolute, mixed row, and mixed column references. On Mac, F4 may require Fn+F4 depending on your keyboard settings. - Fill the formula down and across. Drag the fill handle or copy the cell and paste it into the rows below. Because the lookup value column is locked and the arrays are absolute, every copy searches the same source range but uses the row's own lookup value.
- Add the optional arguments if needed. XLOOKUP's fourth argument handles “not found” text:
=XLOOKUP($A2,$D$2:$D$100,$E$2:$E$100,"Not found"). The fifth argument sets the match mode (0 for exact match, which is the default). The sixth argument sets the search mode (1 for first-to-last, -1 for last-to-first). Keep the default exact match unless you have a specific reason to change it. - Check one copied cell manually. Click a filled cell and confirm the formula bar shows the correct locked references. If the lookup value row number changed but the column stayed locked, the lock is working as intended.
Common Mistakes
- Locking only the lookup value but not the arrays. The formula may work in the first cell and then return wrong results or #REF! errors after filling, because the lookup range slides down with each row.
- Locking the row of the lookup value when you meant to lock the column.
A$2locks the row, so dragging the formula down keeps searching row 2. Use$A2to lock the column instead. - Mixing table and range references. If the source is a table, use structured references throughout; mixing
tblProducts[SKU]with$D$2:$D$100can break when the table grows. - Forgetting that XLOOKUP returns a #N/A error when no match is found. Wrap it with the fourth argument or IFNA if you want a cleaner message.
- Using XLOOKUP in an older Excel version. Excel 2019 and earlier do not have it; the formula will show #NAME?. Use INDEX/MATCH or upgrade.
Tips
- Name your lookup cell (Formulas > Define Name) so the formula reads
=XLOOKUP(SearchSKU,tblProducts[SKU],tblProducts[Price])— easier to audit than$A2. - Use a table for the source and a separate input cell for the search term; lock that input cell's column with
$so one formula can be copied across multiple return columns. - Press Ctrl+` (grave accent) to toggle showing formulas, which makes it easy to spot missing dollar signs across a filled range.
- If you need to return multiple columns at once, XLOOKUP can spill: give it a return array with several columns, e.g.
tblProducts[[Price]:[Stock]], and lock the lookup value the same way.
Troubleshooting
- #N/A after copying: the lookup value probably shifted to an empty cell, or the lookup array moved. Check the dollar signs and confirm the lookup value exists exactly (no trailing spaces).
- #REF! error: a locked range may point outside the sheet after rows were deleted, or the table name was changed. Re-select the range and re-lock it.
- #VALUE! error: the lookup array and return array are different sizes, or the lookup value is an array when a single value is expected. Make both arrays the same number of rows.
- Formula returns the wrong row's result: the lookup value column is not locked, so it moved with the fill. Change
A2to$A2. - XLOOKUP not recognised: confirm your Excel version supports it (Microsoft 365 or Excel 2021). If not, use INDEX/MATCH with the same locking pattern.
Frequently Asked Questions
Do I need to lock every reference in XLOOKUP?
No. Lock only the parts that must not change when you copy the formula — usually the lookup value's column and both arrays. The row number of the lookup value should stay relative so each row searches its own value.
Can I use XLOOKUP with a named range instead of dollar signs?
Yes. A named range is effectively absolute, so =XLOOKUP($A2,ProductSKUs,ProductPrices) works without dollar signs on the arrays.
Why does my XLOOKUP break when I add rows to the source?
If you used fixed ranges like $D$2:$D$100, new rows beyond row 100 are outside the range. Convert the source to an Excel Table and use structured references so the range expands automatically.
Does XLOOKUP work in Excel for the web?
Yes, XLOOKUP is supported in Excel for the web and in Excel for Microsoft 365 desktop apps. It is not available in Excel 2019 or earlier.
How do I lock a reference on a Mac without an F4 key?
Use Fn+F4, or type the dollar signs manually. You can also select the reference and use the shortcut your keyboard mapping provides; check Excel's Formula Editing shortcuts for your Mac layout.