Excel · ChatGPT

Build and Troubleshoot XLOOKUP Formulas with ChatGPT

XLOOKUP is the modern replacement for VLOOKUP — more flexible, easier to read, and available in Microsoft 365 and Excel 2021+. Describe what you want to look up and ChatGPT writes the correct formula with the right match mode, or diagnoses a broken one in seconds.

Choose your situation — copy the prompt:
I need an XLOOKUP formula. I want to look up [lookup value / cell
reference] in [lookup column/range] and return the value from [return
column/range]. Data is on sheet [name], rows 2 to [last row]. Please
write the XLOOKUP and use its built-in [if_not_found] argument for missing values.

One sentence is enough — ChatGPT fills in the exact syntax and match mode. Paste the prompt into ChatGPT.

My XLOOKUP is returning #N/A. Here is the formula:
[paste formula]

The lookup value is [value] and I expect it to correspond to a row in the
table. Here are 3 sample rows from the lookup column:
[paste rows]

Please identify why it's failing and give me the corrected formula.

Common causes include a missing value, data type mismatch, trailing spaces, or inconsistent key formats such as 1041 vs EMP-1041. For a complete diagnosis of spaces, text/number mismatches, and match settings, see Fix #N/A Errors in Excel.

Please convert this VLOOKUP to XLOOKUP:
[paste VLOOKUP formula]

Data is on sheet [name]. Keep any existing IFERROR wrapper.

ChatGPT fixes the hardcoded column index numbers that break when columns are inserted or deleted.

Before — bonus % copied manually from another sheet
Staff
A
B
C
D
1
Emp ID
Name
Salary
Bonus %
2
EMP-041
Sarah Chen
£52,000
manual
3
EMP-087
James Ward
£48,500
manual
4
EMP-112
Priya Patel
£44,000
manual
BonusTable
A
B
1
Emp ID
Bonus %
2
EMP-041
12%
3
EMP-087
18%
4
EMP-112
8%
Manual process: find EMP-041 in BonusTable, copy 12%, paste into Staff!D2. Repeat for every employee and every payroll cycle.
After — XLOOKUP returns the bonus automatically
Staff
D2
fx
=XLOOKUP(A2,BonusTable!A:A,BonusTable!B:B,"Not found",0)
A
B
C
D
1
Emp ID
Name
Salary
Bonus %
2
EMP-041
Sarah Chen
£52,000
12%
3
EMP-087
James Ward
£48,500
18%
4
EMP-112
Priya Patel
£44,000
8%
Lookup path: A2 → BonusTable!A:A → return BonusTable!B:B. Drag D2 down to fill the column.
Before — lookup value format does not match the table
Staff
D2
fx
=XLOOKUP(A2,BonusTable!A:A,BonusTable!B:B)
A
D
1
Lookup ID
Result
2
1041
#N/A
3
1087
#N/A
4
1112
#N/A
BonusTable
A
B
1
Emp ID
Bonus %
2
EMP-1041
12%
3
EMP-1087
18%
4
EMP-1112
8%
Mismatch: Staff stores 1041; BonusTable stores EMP-1041. The IDs are different formats, so XLOOKUP cannot match them.
After — normalize the key before XLOOKUP
Staff
D2
fx
=XLOOKUP("EMP-"&TEXT(A2,"0"),BonusTable!A:A,BonusTable!B:B,"Not found")
A
B
C
D
1
Lookup ID
Normalized key
Match
Result
2
1041
EMP-1041
EMP-1041
12%
3
1087
EMP-1087
EMP-1087
18%
4
1112
EMP-1112
EMP-1112
8%
Fix: prefix the numeric ID with EMP- before looking it up. All three rows now resolve correctly.
Before — inserted column breaks VLOOKUP's hardcoded index
Staff
E2
fx
=IFERROR(VLOOKUP(A2,Staff!A:D,3,FALSE),"—")
A
B
C
D
E
1
Emp ID
Name
Dept (inserted)
Salary
Lookup result
2
EMP-041
Sarah Chen
Finance
£52,000
Finance
3
EMP-087
James Ward
Sales
£48,500
Sales
Problem: Excel expands the referenced table to A:D after Dept is inserted, but VLOOKUP still asks for column 3. Column 3 is now Dept, so E2 returns Finance instead of £52,000.
After — XLOOKUP points directly to the Salary column
Staff
E2
fx
=XLOOKUP(A2,Staff!A:A,Staff!D:D,"—",0)
A
B
C
D
E
1
Emp ID
Name
Dept
Salary
Lookup result
2
EMP-041
Sarah Chen
Finance
£52,000
£52,000
3
EMP-087
James Ward
Sales
£48,500
£48,500
Why it is safer: XLOOKUP references the return column directly, so inserting a new column does not silently shift the result.
Why XLOOKUP returns #N/A — 4 common causes
Value genuinely missing
The lookup value is not present in the lookup array at all
Check first
Data type mismatch
Lookup value is text but the lookup column stores numbers (or vice versa)
Common
Spaces / hidden characters
"EMP-042 " is not the same text as "EMP-042"
Data issue
Inconsistent key format
1041 does not exactly match "EMP-1041" until the key is normalized
This example

How to build an XLOOKUP formula step by step

Write and test an XLOOKUP with ChatGPT — 5 steps
1

Clearly define what you need

Tell ChatGPT the lookup value, the column where it's located, and the column you want to return. One sentence is enough: "Look up employee ID in column A of the Staff sheet and return their salary from column D."

2

Provide the data location

Specify the sheet name, the range, and whether the data has a fixed size or grows. ChatGPT uses this to write references that won't break when rows are added.

3

Get the formula with the right match mode

ChatGPT writes the full XLOOKUP and chooses the right match mode — exact match for IDs and codes, approximate for tiered pricing or grades, wildcard for partial text searches.

4

Test with a known value

Always test with a value you know should work. If it returns #N/A, send ChatGPT the formula and 3 sample rows. Check whether the value is missing, stored as a different data type, padded with spaces, or formatted with a different prefix/suffix.

5

Add error handling and convert old VLOOKUPs

Wrap the formula with IFERROR or use the built-in 4th argument for missing values. Then paste any existing VLOOKUPs into ChatGPT to convert them cleanly — including fixing hardcoded column index numbers.

Version check: XLOOKUP requires Microsoft 365, Excel 2021, or Excel 2024. It is not available in Excel 2019, 2016, or earlier. If you or your colleagues are on an older version, tell ChatGPT and it will write INDEX/MATCH instead — same flexibility, works everywhere.

Frequently asked questions

Is XLOOKUP better than VLOOKUP?
Yes. XLOOKUP improves on VLOOKUP in several important ways: it uses a direct range reference instead of a fragile column index number, it can look left, it has a built-in argument for handling missing values, and its match modes are clearer. XLOOKUP is the recommended replacement wherever Microsoft 365 or Excel 2021+ is available.
Why is my XLOOKUP returning #N/A?
Common causes include a lookup value that is genuinely missing, a data type mismatch between the lookup value and lookup column, trailing spaces or invisible characters, and inconsistent key formats such as 1041 versus EMP-1041. Paste the formula and a few sample rows into ChatGPT to diagnose the mismatch.
What Excel versions support XLOOKUP?
XLOOKUP is available in Microsoft 365, Excel 2021, and Excel 2024. It is not available in Excel 2019, 2016, or earlier. If you are on an older version, use INDEX/MATCH instead — it offers the same flexibility and works in every Excel version.
Does XLOOKUP replace INDEX MATCH?
XLOOKUP and INDEX/MATCH solve the same problems, but XLOOKUP has simpler syntax and built-in error handling. If everyone on your team uses Microsoft 365, Excel 2021, or Excel 2024, XLOOKUP is the cleaner choice. If any colleagues use older versions, INDEX/MATCH is safer because it works everywhere.
Can XLOOKUP return more than one column at once?
Yes. If you need multiple fields from the same lookup — for example both name and salary — describe that to ChatGPT and it will write a single XLOOKUP that spills both results, instead of writing two separate formulas.

Related Excel workflows