Function Problems

How to Find a Column Matching Values in Two Excel Rows

Muhammad TalhaMuhammad Talha Nov 10, 2026 868 views

Question details

The user needs to identify the relative column position where specific criteria match in both the first row (headers) and the second row (subheaders).

How to Find a Column Matching Values in Two Excel Rows
Product
Excel / WPS Spreadsheet
Device & OS
not provided
Scenario
Searching through a worksheet with repeating headers and subheaders to pinpoint the exact column index based on a dual-row criteria match.
Observed behavior
The user aims to output the column index number where the values in two separate rows simultaneously meet two predefined search criteria.
Before you start

Ensure your search criteria are clearly defined in specific reference cells (e.g., B8 and B9) and that the ranges you are comparing (like A1:F1 and A2:F2) have identical column widths. Additionally, verify that your version of Excel or WPS Office supports the XMATCH function or dynamic arrays.

Solution 1Recommended

Use XMATCH with Array Multiplication

This method uses Boolean logic to multiply two conditional arrays together, returning the precise column index where both conditions are TRUE.

By comparing the cell ranges to your criteria, the software creates TRUE/FALSE arrays. Multiplying these two arrays converts the TRUE/FALSE values into 1s and 0s. A 1 only appears when both conditions are met (TRUE * TRUE). The XMATCH function then searches for this 1 to pinpoint the correct column position.

1
Set up your criteria cells

Input your first row's criteria (e.g., 'AR') into a dedicated cell like B8, and your second row's criteria (e.g., 'E') into cell B9.

2
Select the output cell

Click on an empty cell where you want the resulting column index to appear (e.g., cell B10).

3
Enter the XMATCH formula

Type the formula =XMATCH(1,(A1:F1=B8)*(A2:F2=B9)) into the formula bar.

4
Execute the function

Press Enter to apply the formula. The cell will now display the number representing the column position that matches both headers.

Use XMATCH with Array Multiplication
Dynamic Updates: If you update the criteria in B8 or B9, the formula will automatically recalculate and display the new matching column position.
Efficient Data Analysis

Find Matching Columns Easily in WPS Spreadsheet

WPS Spreadsheet fully supports advanced array formulas and functions like XMATCH and MATCH. You can seamlessly perform multi-row data lookups and handle complex datasets without any hassle using a highly compatible and lightweight interface.

  1. 1. Open your dataset: Launch WPS Spreadsheet and open the document containing your multi-row header dataset.
  2. 2. Define the criteria: Type your search terms into distinct, separate cells, such as B8 for the primary header and B9 for the subheader.
  3. 3. Insert the lookup formula: Select the cell for your result and input =XMATCH(1,(A1:F1=B8)*(A2:F2=B9)).
  4. 4. Calculate the result: Press Enter to instantly evaluate the arrays and retrieve the precise column index.
Fully compatible with Microsoft Excel formulas, including XMATCH and dynamic array functions.Lightweight software architecture that processes complex array calculations instantly.User-friendly interface designed for straightforward data manipulation and lookup operations.Free to download and use with a vast, built-in library of advanced spreadsheet functions.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my XMATCH formula return an #N/A error?

An #N/A error indicates that the exact combination of criteria was not found in the specified ranges. Ensure there are no hidden trailing spaces in your headers and that both lookup arrays (e.g., A1:F1 and A2:F2) are exactly the same size.

Can I use this method to match three or more rows?

Yes, you can expand the Boolean logic by multiplying additional array conditions. For example, using =XMATCH(1,(A1:F1=B8)*(A2:F2=B9)*(A3:F3=B10)) will find the column where all three row conditions are simultaneously met.

Do I need to press Ctrl+Shift+Enter for this formula to work?

If you are using modern spreadsheet software with a dynamic array engine (like Microsoft 365 or the latest WPS Office), you only need to press Enter. However, if you are using older legacy versions with the standard MATCH function, you must press Ctrl+Shift+Enter to evaluate it as an array formula.