Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

XLOOKUP in Google Sheets with a Table: How-To

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Google Sheets does not have a function literally named XLOOKUP, but you can build the same lookup behavior with a table using INDEX and MATCH, or with the newer XLOOKUP function if your account has it. The shortest working version is =INDEX(return_range, MATCH(lookup_value, lookup_range, 0)), where the lookup and return ranges are columns in your table. This gives you a left-to-right or right-to-left lookup that is more flexible than VLOOKUP and does not break when you insert columns.

What You'll Need

  • A Google account with access to Google Sheets.
  • A spreadsheet containing a table with a header row and consistent data in each column.
  • The value you want to look up (for example, a product ID or employee name) and the column you want returned.
  • Basic familiarity with cell references and ranges (for example, A2:A100).

Step-by-Step

  1. Set up your table. Put your data in a clean block with one header row. For example, put IDs in column A, names in column B, and departments in column C, starting at row 2. Keep the table free of blank rows and merged cells, because both break lookups.
  2. Decide the lookup column and the return column. The lookup column is the one you search in (for example, column A for IDs). The return column is the one you want back (for example, column C for departments). They do not need to be next to each other.
  3. Pick a cell for the result. Click an empty cell outside the table, such as E2, and type the formula there.
  4. Write the INDEX/MATCH formula. In E2, enter =INDEX(C2:C100, MATCH("A-104", A2:A100, 0)). This searches A2:A100 for the exact text A-104 and returns the matching value from C2:C100. Replace the ranges with your own and replace "A-104" with a cell reference if you prefer, for example =INDEX(C2:C100, MATCH(E1, A2:A100, 0)) where E1 holds the lookup value.
  5. Press Enter and check the result. If the formula returns a value, the lookup is working. If it returns #N/A, the lookup value was not found exactly; check for extra spaces or different data types (text vs. number).
  6. Use XLOOKUP if your account has it. Some Google Workspace accounts and regions now include XLOOKUP. The syntax is =XLOOKUP(lookup_value, lookup_range, return_range), for example =XLOOKUP("A-104", A2:A100, C2:C100). If the function is not available, Sheets will show a #NAME? error, and you should use INDEX/MATCH instead.
  7. Make the ranges absolute for copying. Change relative ranges to absolute with dollar signs, for example $A$2:$A$100 and $C$2:$C$100, so the formula keeps pointing at the table when you drag it down or across.
  8. Copy the formula down. Drag the fill handle from E2 down as many rows as you need. Each row should return the value for its own lookup cell if you used a relative lookup reference.
  9. Wrap it in IFERROR for clean output. Use =IFERROR(INDEX($C$2:$C$100, MATCH(E1, $A$2:$A$100, 0)), "Not found") so missing values show a friendly message instead of an error.
  10. Test with a known value and an unknown value. Confirm the formula returns the correct row for a value you can verify by eye, and confirm it returns your fallback text for a value that does not exist.

Common Mistakes

  • Mismatched range sizes. INDEX and MATCH ranges must cover the same number of rows, or the row number returned by MATCH will point to the wrong row in INDEX.
  • Using approximate match. Leaving out the 0 in MATCH makes it approximate, which returns wrong results on unsorted data. Always include 0 for an exact match.
  • Text that looks like a number. IDs stored as text will not match IDs stored as numbers. Use consistent formatting or convert with VALUE or TEXT.
  • Hidden spaces. Trailing spaces from imports cause #N/A. Use TRIM on the lookup value or clean the source data.
  • Relative ranges when copying. Without dollar signs, ranges shift as you fill down and start missing rows.
  • Assuming XLOOKUP is always available. It is not universal in Google Sheets; if you get #NAME?, fall back to INDEX/MATCH.

Tips

  • Name your table ranges (Data > Named ranges) so formulas read as =INDEX(Department, MATCH(E1, ID, 0)).
  • Use a cell reference for the lookup value rather than typing it into the formula, so you can change it without editing the formula.
  • For a two-way lookup, nest a second MATCH inside INDEX to find the column number as well as the row number.
  • Keep the lookup column free of duplicates if you expect a single answer; duplicates return the first match only.
  • Use Data > Data cleanup > Trim whitespace on imported tables before building lookups.

Troubleshooting

If the formula returns #N/A, check that the lookup value exists exactly, with no extra spaces and matching data type. If it returns #REF!, one of your ranges is invalid or points outside the sheet. If it returns #NAME?, the function name is misspelled or XLOOKUP is not available in your account, so switch to INDEX/MATCH. If the result is the wrong row, confirm the INDEX and MATCH ranges start and end on the same rows. If the formula works in one cell but not when copied, check that the ranges are absolute. If the sheet is slow with large tables, limit ranges to the actual data instead of whole columns.

Frequently Asked Questions

Does Google Sheets have XLOOKUP?

Some accounts and regions have XLOOKUP, but it is not guaranteed everywhere. INDEX with MATCH works in all versions and gives the same result.

Can XLOOKUP search to the left?

Yes. XLOOKUP and INDEX/MATCH can return a column to the left of the lookup column, unlike VLOOKUP, which only searches to the right.

Why does my lookup return #N/A when the value is visible?

Usually a data type mismatch or hidden spaces. Check for text stored as numbers and trim whitespace in both the lookup value and the source column.

Can I look up across two tables?

Yes, as long as both tables are in the same spreadsheet. Reference the lookup range in one table and the return range in the other.

What is the difference between XLOOKUP and VLOOKUP here?

VLOOKUP requires the lookup column to be the first column in the range and counts columns by position. XLOOKUP and INDEX/MATCH use explicit ranges, so inserting a column does not break them.

Can I return multiple columns at once?

With XLOOKUP you can point the return range at several columns and it spills the results. With INDEX/MATCH, copy the formula across columns or use a second MATCH for the column position.