Function Problems

How to Return the Second Matching Column with XLOOKUP or INDEX MATCH in Excel

Algirdas JasaitisAlgirdas Jasaitis Oct 26, 2026 870 views

Question details

The user needs a formula to retrieve a value corresponding to the second occurrence of a repeated column header for a specific parameter.

How to Return the Second Matching Column Using XLOOKUP or INDEX MATCH in Excel
Product
Excel
Device & OS
not provided
Scenario
Looking up data across worksheets where column headers are repeated, and retrieving the specific value for the second parameter.
Observed behavior
Standard lookup formulas only return the first occurrence of the matching header, ignoring the subsequent occurrences required for the second parameter.
Before you start

Ensure your spreadsheet software supports the XLOOKUP function. If you are using an older version without XLOOKUP, you will need to use the INDEX and MATCH solution instead.

Solution 1Recommended

Use a Nested XLOOKUP Formula

Implement a nested XLOOKUP function to dynamically fetch the correct array intersection, even when column headers repeat.

By nesting one XLOOKUP inside another, you can dynamically define both the row array and the column array. This technique allows Excel to pinpoint the exact cell where the second parameter's criteria meet, avoiding the limitation of stopping at the first match.

1
Select the target cell

Click on the cell where you want the result to appear (for example, cell J2).

2
Enter the nested XLOOKUP formula

Type `=XLOOKUP($I2, $E$2:$G$2, XLOOKUP(J$1, $A$3:$A$4, $E$3:$G$4))` into the formula bar. Ensure you adjust the absolute and relative cell references based on your actual data layout.

3
Apply and fill the formula

Press Enter to calculate the result, then drag the fill handle at the bottom-right corner of the cell across the desired columns and down the rows.

Use a Nested XLOOKUP Formula
Data Range Adjustment: Double-check your absolute references (like $E$3:$G$4). Correct locking of cells is required to successfully copy the formula across other cells without breaking the lookup logic.
Advanced Formulas in WPS Office

Effortlessly Manage Complex Data Lookups with WPS Spreadsheet

WPS Spreadsheet fully supports advanced functions like XLOOKUP, INDEX, and MATCH, making it incredibly easy to retrieve specific data from complex layouts seamlessly.

  1. 1. Open your data file: Launch WPS Spreadsheet and open the workbook containing your duplicated column headers.
  2. 2. Insert the XLOOKUP function: Select your target cell, go to the Formula tab, and click Insert Function to easily build your nested XLOOKUP formula.
  3. 3. Calculate and evaluate: Press Enter to retrieve the exact lookup value and confidently drag the formula across your grid.
Fully compatible with Microsoft Excel formulas, functions, and file formats (.xlsx).Includes native support for modern functions like XLOOKUP out of the box.Free and lightweight, running smoothly on Windows, Mac, and Linux systems.
QA img-9

Frequently Asked Questions

Why does VLOOKUP only return the first matching value?

VLOOKUP searches from top to bottom (or left to right in the case of HLOOKUP) and stops at the very first exact match it encounters. To return a second occurrence or perform a two-dimensional lookup, you must use more advanced formulas like nested XLOOKUP, INDEX MATCH, or FILTER.

Does WPS Spreadsheet support the XLOOKUP function?

Yes, the latest versions of WPS Office fully support the XLOOKUP function. You can use it exactly as you would in Microsoft Excel without needing to adjust the syntax.

How do I handle #N/A errors when my formula doesn't find a match?

If using XLOOKUP, you can use the built-in [if_not_found] argument, such as `=XLOOKUP(A1, B:B, C:C, "Not Found")`. If you are using INDEX and MATCH, wrap your formula in an IFERROR function, like `=IFERROR(INDEX(...), "Not Found")`.