Two-Way Lookup in Excel and Google Sheets

Find the value where a row label and column header intersect in Excel or Google Sheets, using INDEX with two MATCH functions or a nested XLOOKUP.

On this page

You have sales reps listed down the left side of a spreadsheet and months across the top. You need the figure for one rep in one month, but a normal vertical lookup only finds the row. To look up multiple criteria horizontally and vertically in Excel or Google Sheets, you need the intersection of a row label and a column header.

Here is a sales grid in B2:F8. Enter the rep names in B3:B8, the month headers in C2:F2 as plain text, not dates, and the numeric sales values in C3:F8.

RowBCDEF
2RepJanFebMarApr
3Olivia9801,1201,2401,360
4Noah1,4501,3101,5801,420
5Emma8709601,0901,180
6Liam1,7201,6401,8101,950
7Ava1,1301,2601,3401,410
8Ethan1,3901,4701,5201,680

Enter Olivia in H2 and Mar in H3. In H4, enter:

=INDEX(C3:F8,MATCH(H2,B3:B8,0),MATCH(H3,C2:F2,0))

The formula returns 1,240, the value where Olivia’s row crosses the Mar column. Change H2 to Liam and it returns 1,810; change H3 to Apr as well and it returns 1,950. Both lookup directions update without rewriting the formula.

Google Sheets with H4 selected, showing =INDEX(C3:F8,MATCH(H2,B3:B8,0),MATCH(H3,C2:F2,0)) in the formula bar and 1,240 in H4. The sales grid in B2:F8 lists six reps by month, with Olivia in H2 and Mar in H3.
Screenshot: Google Sheets, Nov 2026

Why INDEX needs two MATCH functions

A standard INDEX/MATCH lookup finds a position in one direction. A two-way lookup needs two: one for the row and one for the column.

The first MATCH searches B3:B8 for Olivia and returns 1, because Olivia is the first rep in that range. The second MATCH searches C2:F2 for Mar and returns 3, because Mar is the third header. INDEX then retrieves the value at row 1, column 3 of C3:F8, which is E3.

The INDEX range contains only the numeric sales values. The rep names and month headers stay outside it.

A range that starts at B2 returns the wrong month

The most common range mistake is including the header row or the rep-name column inside INDEX:

=INDEX(B2:F8,MATCH(H2,B3:B8,0),MATCH(H3,C2:F2,0))

For Olivia and Mar, both MATCH functions still return 1 and 3, so INDEX retrieves row 1, column 3 of B2:F8. That cell is D2, and the result is Feb, not 1,240. The lookup positions are correct relative to their MATCH ranges, but those positions no longer line up with the INDEX range.

Google Sheets with H4 selected, showing =INDEX(B2:F8,MATCH(H2,B3:B8,0),MATCH(H3,C2:F2,0)) in the formula bar and Feb in H4. Because the INDEX range starts at B2, row 1, column 3 lands on the Feb header in D2 instead of Olivia's March sales.
Screenshot: Google Sheets, Nov 2026

When you adapt the formula, the INDEX range should start at the first numeric data cell, the row-label range should start on the same worksheet row, and the header range should start in the same worksheet column. The INDEX range needs the same number of rows as the row labels and the same number of columns as the headers.

A hard-coded VLOOKUP column index is also a liability in a grid that gains new months. A two-way lookup finds the column by its header rather than by a fixed position.

The same lookup with nested XLOOKUP

You can also find the intersection with two XLOOKUP functions. With the same grid and lookup cells:

=XLOOKUP(H2,B3:B8,XLOOKUP(H3,C2:F2,C3:F8))

This also returns 1,240 for Olivia and Mar. Read it from the inside out. The inner XLOOKUP, =XLOOKUP(H3,C2:F2,C3:F8), finds Mar in C2:F2 and returns the corresponding sales column. Entered on its own, it spills the six March figures: 1,240, 1,580, 1,090, 1,810, 1,340, and 1,520. The outer XLOOKUP then finds Olivia in B3:B8 and retrieves her value from that column.

Neither the nested formula nor the inner spill needed an ARRAYFORMULA wrapper in Google Sheets. That is different from some multiple-criteria lookups that build arrays of combined conditions and do need ARRAYFORMULA in Sheets.

I prefer INDEX/MATCH/MATCH for this kind of grid. The row and column references are explicit, and it is easier to inspect each MATCH separately when the result is wrong. For a broader comparison of lookup methods, see XLOOKUP vs INDEX/MATCH vs VLOOKUP. I did not run these formulas in Excel. In Google Sheets they work as written. Excel’s XLOOKUP is a Microsoft 365 / Excel 2021 function, so INDEX/MATCH/MATCH is also the version I would reach for if the file has to open in older Excel.

Two-way lookup is not the same as two conditions in one row

People describe two different problems as an Excel lookup with multiple criteria. In this article, one criterion identifies a row and the other identifies a column, and the answer is the single cell where they intersect.

A different problem is finding a record where two conditions are true in the same row, such as matching both a customer ID and an order status. That structure is covered in XLOOKUP with multiple criteria. Trying to combine the rep and month labels as two AND-conditions on the same row does not match the layout of this sales grid.

Approximate MATCH picks the wrong month

Both MATCH functions need an explicit 0 for an exact match. Without the third argument, MATCH defaults to type 1: it assumes the lookup range is sorted in ascending order and looks for the largest value less than or equal to the lookup value. These month headers are arranged chronologically, not alphabetically, so that assumption does not hold.

=MATCH(H3,C2:F2)

With Mar in H3, this returned 4, the position of Apr, not 3. The two-way formula that used this default MATCH returned Olivia’s April sales instead of March:

=INDEX(C3:F8,MATCH(H2,B3:B8,0),MATCH(H3,C2:F2))

That formula returned 1,360, not 1,240.

The other months were no safer. =MATCH("Jan",C2:F2) returned 2 (Feb). =MATCH("Apr",C2:F2) returned #N/A, with the message “Did not find value ‘Apr’ in MATCH evaluation,” even though Apr is in C2:F2. =MATCH("May",C2:F2), a month that is not in the header row, returned 4 rather than an error, and INDEX then returned 1,360 again. A missing month looked like April’s sales.

The same thing happens on the row labels. =MATCH(H2,B3:B8) with Olivia in H2 returned 6, the last name in the list, and INDEX then returned 1,520, Ethan’s March figure.

Use =MATCH(H3,C2:F2,0), which returns 3 for Mar, and the same explicit 0 on the rep-name MATCH.

A missing row or column label returns #N/A

If you change H2 to Sophia, the original INDEX/MATCH/MATCH formula returns #N/A, with the message “Did not find value ‘Sophia’ in MATCH evaluation.” The same error appears if H3 contains May, which is not in C2:F2: “Did not find value ‘May’ in MATCH evaluation.”

To see which key is missing, run the MATCH functions separately. =MATCH(H2,B3:B8,0) returns #N/A for Sophia, while =MATCH(H3,C2:F2,0) still returns 3 for Mar.

If a missing lookup is expected in your workbook, wrap the complete formula in IFNA:

=IFNA(INDEX(C3:F8,MATCH(H2,B3:B8,0),MATCH(H3,C2:F2,0)),"Not found")

With Sophia and Mar, it returns Not found. With Olivia and Mar, it returns 1,240. IFNA handles #N/A without hiding unrelated error types. For more detail, see IFERROR vs IFNA and why XLOOKUP returns #N/A. Don’t replace every lookup error with zero; a missing rep and a genuine sales value of zero mean different things.

Month headers that look like text but are dates

The sample uses text headers such as Jan, Feb, Mar, and Apr. Real workbooks often use actual dates formatted to show abbreviated month names. A cell containing March 1, 2026 can display as Mar, but its underlying value is a date serial number.

In a test grid where C2:F2 were first-of-month dates for 2026, formatted mmm, ISNUMBER(E2) returned TRUE and the cell displayed Mar. With the text Mar in H3, =MATCH(H3,C2:F2,0) returned #N/A: “Did not find value ‘Mar’ in MATCH evaluation.”

If your headers are real first-of-month dates, use a matching date as the lookup key. With H3 containing March 1, 2026, the original INDEX/MATCH/MATCH formula returned 1,240. Formatting both H3 and E2 as mmm does not change the underlying dates.

A header with a different day of the month is not an exact match, even when both cells display as Mar. With H3 set to March 15, 2026 (serial 46096) and the headers still first-of-month dates, MATCH returned #N/A, and the message was “Did not find value ‘46096’ in MATCH evaluation.” The message quotes the serial, not the displayed month name. Normalize header dates and the lookup key to the same month-start dates before using exact MATCH.

A trailing space or non-breaking space hides the match

A label can also look correct while containing an extra character. If B3 contains Olivia followed by a trailing space, and H2 contains Olivia, =MATCH(H2,B3:B8,0) returns #N/A: “Did not find value ‘Olivia’ in MATCH evaluation.” LEN(B3) returns 7 and LEN(H2) returns 6. UNICODE of the last character in B3 is 32, an ordinary space, and TRIM(B3) returns Olivia.

A non-breaking space is different. For Olivia followed by UNICHAR(160), LEN is also 7 and MATCH still returns #N/A, but TRIM leaves the character in place (LEN stays 7). This cleanup produces Olivia:

=TRIM(SUBSTITUTE(B3,UNICHAR(160)," "))

Use the cleaned label in your lookup range, or replace the bad source value. Cleaning only the lookup key won’t fix an inconsistent source column.

Duplicate rep names return the first matching row

MATCH with type 0 returns the position of the first exact match, not every matching row. After B4 was changed from Noah to Olivia, =MATCH("Olivia",B3:B8,0) still returned 1, and the two-way lookup still returned 1,240 for Olivia and Mar. It did not retrieve the second Olivia’s March value of 1,580. =COUNTIF(B3:B8,H2) returned 1 on the original grid and 2 after the duplicate.

If your grid has duplicate rep names, decide what identifies a unique row: an employee ID, a team-specific identifier, or a separate row for each rep and region. A two-way lookup assumes the row and column keys identify the intended intersection.

Keep the three ranges aligned when the grid grows

If you add May in column G, expand both the numeric body and the header range:

=INDEX(C3:G8,MATCH(H2,B3:B8,0),MATCH(H3,C2:G2,0))

With the original March lookup, this still returned 1,240. The row lookup stays the same; only the sales body and month-header ranges need to grow.

Oscar

Spreadsheet nerd who writes about Excel and Google Sheets formulas.

Google Sheets, 23 November 2026, new private unshared spreadsheet (locale en_US, timezone America/New_York; 1000-row by 26-column grid). Sample values were written as literal cell values; formulas were entered as user input through the Sheets API. Date headers used DATE() and were formatted mmm. Error text was read from the Sheets API error message, not from a hover tooltip. Excel was not run.

Next in Lookup & Conditional Sums FILTER Wildcard Not Working in Excel and Google Sheets