logo
search
Function Problems

How to Use XLOOKUP and Structured References to Match IDs in Excel

Ayan MasoodAyan Masood Oct 22, 2026 869 views

Question details

The user needs to match patient or medical IDs across different worksheets to return a specific value, utilizing XLOOKUP and structured references for named tables.

How to Use XLOOKUP and Structured References to Match IDs in Excel
Product
Excel
Device & OS
not provided
Scenario
Looking up data across worksheets where the source data is formatted as a named table, and specifically handling column headers that contain special characters.
Observed behavior
The user needs the correct syntax to reference table names instead of sheet names, and the proper way to escape special characters (like the number sign) within structured references to make the lookup formula work.
Before you start

Ensure your source data is formatted as an official Table (Ctrl+T) and check the exact name of the table in the Table Design tab before writing your lookup formula.

Solution 1Recommended

Use XLOOKUP with Structured Table References

Use this method to look up values using exact table names instead of generic worksheet and cell ranges, which makes your formulas dynamic and easier to read.

When your source data is stored in a named table, you should reference the table name directly rather than the worksheet name. This ensures that even if the table moves or grows, your XLOOKUP formula will continue to target the correct data.

1
Identify your Table Name

Click anywhere inside your source data table, go to the 'Table Design' tab on the ribbon, and note the name in the 'Table Name' box (e.g., Table2).

2
Write the XLOOKUP Formula

In your destination cell, start your formula with =XLOOKUP(.

3
Input the Lookup Value and Arrays

Select the cell containing the ID you want to look up, then reference the source table columns. For example: =XLOOKUP(A2, Table2[Patient ID], Table2[Sex]).

4
Execute the Formula

Press Enter to return the matching value. The formula will automatically search the Patient ID column in Table2 and return the corresponding value from the Sex column.

Use XLOOKUP with Structured Table References
Dynamic Updates: Using structured references like Table2[Patient ID] ensures your formula automatically includes new data added to the bottom of the table without needing to adjust the formula range.
Efficient Data Matching

Use WPS Spreadsheet to Seamlessly Match Data with XLOOKUP

WPS Spreadsheet offers full support for advanced lookup functions like XLOOKUP and structured table references, making data matching across sheets quick and error-free.

  1. 1. Open Your Data File: Launch WPS Spreadsheet and open the workbook containing your patient data.
  2. 2. Format as Table: Select your source data, press Ctrl+T to format it as a table, and note the table name in the Table Tools tab.
  3. 3. Enter the XLOOKUP Formula: In your target cell, type =XLOOKUP( to begin the function.
  4. 4. Apply Structured References: Select your lookup value, then enter the table references (e.g., Table1[Patient ID], Table1[Sex]). Remember to use an apostrophe to escape special characters like '#'.
  5. 5. Get Your Results: Press Enter to instantly retrieve the matched data across your worksheets.
Fully compatible with Microsoft Excel formulas and structured table references.Supports modern dynamic array functions including XLOOKUP.Lightweight, fast, and free to use for complex data analysis tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my XLOOKUP returning an error when referencing another sheet?

You might be referencing the worksheet name instead of the named Table. When source data is formatted as an official Excel table, you must use the table's specific name (e.g., Table2[Patient ID]) in the formula rather than standard cell references.

How do I escape special characters like the number sign (#) in a table column name?

To use a column name containing a '#' in a structured reference, you must precede the number sign with an apostrophe. For example, type [@[Patient ID/Medical '#]] to successfully reference the column without triggering an error.

Does XLOOKUP work automatically when new rows are added to my data?

Yes, provided you are using structured table references (like TableName[ColumnName]). Structured references are dynamic, meaning they automatically expand to include new rows added to the bottom of the table, ensuring your XLOOKUP formula always searches the complete dataset.