ElyxAI
formulas

How to How to Create Two-Way Lookup in Excel

Excel 2016Excel 2019Excel 2021Excel 365

Learn to create two-way lookups that search data in both rows and columns simultaneously. This technique combines INDEX and MATCH functions to retrieve values from a matrix using both row and column criteria, eliminating the need for multiple nested lookups and saving time on complex data analysis tasks.

Why This Matters

Two-way lookups are essential for analyzing matrices and cross-tabulated data, common in financial reports, inventory management, and sales analysis. Mastering this skill eliminates manual searching and reduces errors in complex datasets.

Prerequisites

  • Familiarity with INDEX and MATCH functions
  • Understanding of absolute vs. relative cell references
  • Knowledge of basic spreadsheet structure and data organization

Step-by-Step Instructions

1

Prepare your data matrix

Organize your data in a table with row headers in column A and column headers in row 1. Ensure all data is properly aligned with no merged cells or gaps.

2

Create input cells for criteria

Designate two cells (e.g., E2 for row criteria, F2 for column criteria) where users will enter their lookup values.

3

Build the INDEX-MATCH formula

Enter formula: =INDEX($A$1:$E$10,MATCH(E2,$A$1:$A$10,0),MATCH(F2,$A$1:$E$1,0)) where the first range is your data matrix, E2 is your row lookup value, and F2 is your column lookup value.

4

Set absolute references for the matrix

Use dollar signs ($) around your entire data range ($A$1:$E$10) so the range doesn't shift if you copy the formula down or across.

5

Test and validate results

Enter test values in your criteria cells (E2, F2) and verify the formula returns the correct intersection value from your matrix.

Alternative Methods

Using XLOOKUP (Excel 365 only)

In Excel 365, use =XLOOKUP(E2,A:A,INDEX(A:E,0,MATCH(F2,1:1,0))) for a simpler, more flexible syntax that handles errors automatically.

Using SUMPRODUCT for conditions

Apply =SUMPRODUCT((A$1:A$10=E2)*(1:1=F2)*($A$1:$E$10)) when you need to sum values meeting multiple criteria instead of returning a single value.

Pivot table approach

Create a pivot table from your source data, then use standard VLOOKUP or INDEX-MATCH to query the pivot table results for a more dynamic solution.

Tips & Tricks

  • Always use absolute references ($) for your matrix range to prevent formula errors when copying.
  • Place your lookup criteria in clearly labeled cells above or beside the formula for easy user input.
  • Use IFERROR to wrap your formula and display a friendly message if lookup values aren't found: =IFERROR(INDEX(...),"Not found").
  • Test with exact matches (0 in MATCH) for precise data; use 1 for approximate matches only with sorted data.

Pro Tips

  • Use named ranges for your matrix (Data > Define Name) to make formulas more readable: =INDEX(DataMatrix,MATCH(...),MATCH(...)).
  • Combine with data validation (Data > Data Validation) to create dropdown lists for criteria cells, preventing lookup errors from typos.
  • Use MATCH with wildcards if exact matches fail: MATCH(E2&"*",$A$1:$A$10,0) searches for values starting with E2's content.

Troubleshooting

Formula returns #N/A error

The lookup value doesn't exist in your data. Check spelling, spacing, and data types in both the criteria cells and the matrix. Use IFERROR to handle missing values gracefully.

Formula returns wrong value or header text

Verify your MATCH functions are finding the correct row and column positions. Ensure headers start in row 1 and column A with no offset. Use F9 to evaluate each MATCH separately.

Formula shifts incorrectly when copied

Confirm all references in your INDEX and outer MATCH ranges use absolute references ($A$1:$E$10), while criteria cell references (E2, F2) should remain relative.

Case sensitivity issues with text lookups

MATCH is case-insensitive by default. Use EXACT function within SUMPRODUCT if you need case-sensitive matching: =SUMPRODUCT(EXACT(E2,A:A)*...).

Related Excel Formulas

Frequently Asked Questions

Can I use two-way lookup with unsorted data?
Yes, INDEX-MATCH works with unsorted data as long as you use 0 (exact match) in the MATCH function. VLOOKUP requires sorted data for approximate matches, but INDEX-MATCH does not.
What's the difference between two-way lookup and a pivot table?
Two-way lookup is a formula-based solution that updates dynamically with your source data and allows custom criteria cells. Pivot tables are snapshot summaries that require manual refresh but are more powerful for data analysis and grouping.
How do I handle errors if a lookup value isn't found?
Wrap your INDEX-MATCH formula with IFERROR: =IFERROR(INDEX(...),"Value not found"). This displays a custom message instead of #N/A, making your spreadsheet more user-friendly.
Can I use two-way lookup across multiple sheets?
Yes, reference other sheets in your INDEX range: =INDEX(Sheet2!$A$1:$E$10,MATCH(E2,Sheet2!$A$1:$A$10,0),MATCH(F2,Sheet2!$A$1:$E$1,0)). Use absolute references to sheet names to prevent errors.
Is XLOOKUP better than INDEX-MATCH for two-way lookups?
XLOOKUP (Excel 365+) is simpler and handles errors automatically, but INDEX-MATCH works across all Excel versions. Choose XLOOKUP for modern Excel environments; use INDEX-MATCH for broader compatibility.

This was one task. ElyxAI handles hundreds.

Sign up