How to Look Up a Horizontal Excel Table and Return a Vertical Result
Question details
The user needs to find a specific guest name within a horizontal 2D seating table and return the corresponding table number to a vertical attendance sheet.

- Product
- Excel / WPS Spreadsheet
- Device & OS
- not provided
- Scenario
- Managing event seating charts and tracking attendance using dynamic-array lookup functions.
- Observed behavior
- The goal is to correctly identify the column containing a match in a 2D range and extract the horizontal header (table number) into a vertical list.
Ensure your spreadsheet software is up to date and supports modern dynamic-array functions like XLOOKUP, BYCOL, and LAMBDA.
Use XLOOKUP, BYCOL, and LAMBDA Functions
This method combines dynamic arrays to search a 2D range and return the corresponding column header, perfect for finding a value in a horizontal table.
Searching for a value across multiple rows and columns requires checking the entire grid. This formula compares every cell in your target range against the lookup value. It then uses BYCOL and LAMBDA to sum the matches in each column. Finally, XLOOKUP finds the column with a match (where the sum is 1) and returns the corresponding table number from the header row.
Click on the cell in your vertical attendance sheet where you want the table number to appear.
Enter the formula: =XLOOKUP(1, BYCOL(--(E5:K16=target_name), LAMBDA(column, SUM(column))), E4:K4)
Replace 'E5:K16' with the actual cell range of your horizontal seating table where the guest names are located.
Replace 'target_name' with the cell reference containing the specific guest name you are looking up (for example, A2).
Replace 'E4:K4' with the range containing your table numbers (the horizontal headers of your seating table).
Press Enter to apply the formula. You can then drag the fill handle down to apply this lookup to the rest of your vertical list.

Handle Complex Lookups Effortlessly in WPS Office
WPS Spreadsheet fully supports modern dynamic-array functions like XLOOKUP, BYCOL, and LAMBDA. You can seamlessly perform 2D table lookups and manage complex data operations without requiring complicated VBA scripts.
- 1. Open your seating chart: Launch WPS Spreadsheet and open the workbook containing your horizontal table and vertical list.
- 2. Enter the formula: Select the destination cell and input the XLOOKUP and BYCOL formula exactly as you would in Excel.
- 3. Get instant results: Press Enter. WPS Spreadsheet will instantly calculate the dynamic array and fetch your table number.

Frequently Asked Questions
Why does my XLOOKUP formula return an #N/A error?
An #N/A error usually occurs if the target name doesn't exist in the data range (e.g., E5:K16). Double-check for typos, extra spaces, or misspellings in both your lookup value and the source table.
Can I use INDEX and MATCH instead of XLOOKUP for this?
While INDEX and MATCH are powerful, searching across multiple columns and rows (a 2D array) to return a single header is highly complex with them. Using XLOOKUP combined with BYCOL and LAMBDA is the most efficient and beginner-friendly approach for this specific scenario.
What does BYCOL do in this formula?
The BYCOL function applies a custom LAMBDA calculation (in this case, summing the values) to each column in an array individually. It helps identify exactly which column contains the matching name.




