Use Excel XLOOKUP and XMATCH to Return Values by Column Heading
Question details
Return product values by matching both a product identifier and a column heading.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A results table needs to retrieve product information from a source table and use the same formula across multiple result columns.
- Observed behavior
- Each result column should display the value from the matching product row and source-table heading.
Make sure your Excel version supports XLOOKUP and XMATCH, and check that the source and result headings match. The example uses tables named Products and Results, each with a Product ID column.
Combine XLOOKUP and XMATCH to Match a Product and Heading
Use this formula when your source and result data are Excel tables and you want to fill the formula across result columns.
XMATCH locates the current result heading in the Products table. INDEX returns that source column, and XLOOKUP finds the value for the current product ID.
Select each table and check its name on the Table Design tab. Name the source table Products and the output table Results. Make sure both have a Product ID column and that the Results heading Unit Price also exists in Products.
In the first data cell under Unit Price in the Results table, enter: =XLOOKUP(Results[@[Product ID]:[Product ID]],Products[[Product ID]:[Product ID]],INDEX(Products,0,XMATCH(Results[[#Headers],[Unit Price]],Products[#Headers],0)),"Not found")
Drag the formula cell's fill handle across the adjacent result columns. The heading reference changes for each column, while the Product ID references remain fixed. Fill down if Excel does not automatically populate the table column.

Match Products and Headings in WPS Spreadsheets
Use INDEX and MATCH in WPS Spreadsheets to retrieve a value at the intersection of a product row and a matching heading.
- 1. Open the workbook: Open your workbook in WPS Spreadsheets. For this example, place the source headings in G1:J1, product IDs in G2:G100, and source data in G2:J100.
- 2. Set up the result headings: Enter result product IDs in column A and matching source headings, such as Unit Price, in row 1 starting at B1.
- 3. Enter the formula: Select B2 and enter: =IFERROR(INDEX($G$2:$J$100,MATCH($A2,$G$2:$G$100,0),MATCH(B$1,$G$1:$J$1,0)),"Not found")
- 4. Fill and check the results: Drag the fill handle across and down the result range. If a cell shows "Not found," check that its product ID and heading match the source data.

Frequently Asked Questions
Can I use Product Name instead of Product ID?
Yes. Replace the Product ID references in the formula with Product Name references in both tables. Use names that uniquely identify each product.
Why does the formula return #N/A when the product exists?
XMATCH may not find the result column heading in Products. Compare the heading in the Results table with the corresponding heading in Products, including any extra spaces.
Can I use MATCH instead of XMATCH?
Yes. In the INDEX portion of the Excel formula, replace XMATCH(Results[[#Headers],[Unit Price]],Products[#Headers],0) with MATCH(Results[[#Headers],[Unit Price]],Products[#Headers],0). Both use 0 for an exact match.
What if my Excel version does not have XLOOKUP?
Use INDEX with two MATCH functions: one to locate the product row and another to locate the heading column. The WPS example on this page shows the same approach with cell ranges.




