How to Use XLOOKUP and Structured References to Match IDs in Excel
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.

- 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.
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.
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.
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).
In your destination cell, start your formula with =XLOOKUP(.
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]).
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.

Escape Special Characters in Structured References
Use this syntax correction when your table column headers contain special characters like the number sign (#) that break standard structured references.
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. Open Your Data File: Launch WPS Spreadsheet and open the workbook containing your patient data.
- 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. Enter the XLOOKUP Formula: In your target cell, type =XLOOKUP( to begin the function.
- 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. Get Your Results: Press Enter to instantly retrieve the matched data across your worksheets.

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.




