Dynamically Reference Excel Table Cells by Header and ID
Question details
Create dynamic Excel table references using an ID and header names stored in the current row.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A table contains an ID and cells whose values identify the columns to retrieve.
- Observed behavior
- The desired formula returns values from the columns named in the current row, using the ID to locate the matching table row.
Confirm that your data is an Excel table named Table1 with unique values in its ID column. Check that R_Val and L_Val are column names containing exact matches for the headers you want to retrieve.
Use INDEX and MATCH with structured table references
Look up the row by ID and the column by the header stored in the current row.
The first MATCH finds the ID in Table1[ID], and the second finds the requested header in Table1[#Headers]. INDEX returns the value at their intersection.
In Table1, add a column for the value identified by R_Val. Make sure the target header does not refer to this result column.
In the new column, enter =INDEX(Table1,MATCH([@ID],Table1[ID],0),MATCH([@R_Val],Table1[#Headers],0)). Excel can fill the formula down the table.
Add another result column and enter =INDEX(Table1,MATCH([@ID],Table1[ID],0),MATCH([@L_Val],Table1[#Headers],0)).
Compare the returned values with the columns named in R_Val and L_Val. If a formula returns #N/A, check that the ID and header text have matching values.

Look up values by ID and header in WPS Spreadsheet
Use INDEX and MATCH in WPS Spreadsheet to retrieve values using an ID and a header named in the current row. This range-based approach provides a similar result without structured table references.
- 1. Open the workbook: Open WPS Spreadsheet and select Open to load your Excel workbook.
- 2. Arrange the lookup data: For this example, place IDs in A2:A100, values in B2:C100, their headers in B1:C1, and the desired header for each row in column D.
- 3. Enter the formula: In E2, enter =INDEX($B$2:$C$100,MATCH(A2,$A$2:$A$100,0),MATCH(D2,$B$1:$C$1,0)).
- 4. Fill and check: Drag the fill handle from E2 down the result column. Extend the referenced ranges if your data grows beyond the specified rows or columns.

Frequently Asked Questions
What does [@R_Val] mean in the formula?
It refers to the value in the R_Val column of the current table row. That value must match the header of the column you want to retrieve.
Why does the formula return #N/A?
Check the current row's ID against Table1[ID] and its R_Val or L_Val text against the table headers. MATCH with 0 requires an exact match.
What happens if two rows have the same ID?
MATCH returns the first matching ID, so the result may come from an earlier row. Use unique IDs or a lookup method that accounts for additional criteria.
Can I use named cells instead of R_Val and L_Val table columns?
Yes. If R_Val is a defined name rather than a table column, use MATCH(R_Val,Table1[#Headers],0) for the column lookup instead of MATCH([@R_Val],Table1[#Headers],0).




