Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Lookup Multiple Criteria Rows and Columns Guide

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To look up a value based on multiple criteria across both rows and columns in Excel, the most reliable method is combining the INDEX function with two MATCH functions: one for the row and one for the column. This creates a two-way lookup (matrix lookup) that can handle complex datasets where you need to find the intersection of a specific row attribute and a specific column header.

What You'll Need

  • A dataset organized in a table or matrix format with clear headers for both rows and columns.
  • Microsoft Excel (this method works across all modern versions, including Office 365, Excel 2021, 2019, and 2016).
  • A basic understanding of cell references (e.g., A1, B2:D10).
  • The specific criteria you are searching for (e.g., a specific Product ID for the row and a specific Month for the column).

Step-by-Step

  1. Organize Your Data Matrix: Ensure your data is structured as a grid. For example, your row headers (Criteria 1) should be in the leftmost column (Column A), and your column headers (Criteria 2) should be in the top row (Row 1). The actual values you want to retrieve should be in the center of the grid.
  2. Identify Your Lookup Values: Set aside two cells where you will input your search criteria. For instance, cell G1 could be for the Row Lookup Value (e.g., "Employee Name") and cell G2 could be for the Column Lookup Value (e.g., "Quarter 3").
  3. Start the INDEX Function: In the cell where you want the result to appear, type =INDEX(. Now, select the entire range of data that contains the values you want to retrieve, excluding the headers. For example, if your data values are in cells B2 through E10, your formula starts as =INDEX(B2:E10,.
  4. Create the Row MATCH: After the first comma in the INDEX function, you need to tell Excel which row to look in. Type MATCH(G1, A2:A10, 0).
    • G1 is the cell containing the value you are searching for in the rows.
    • A2:A10 is the range of the row headers.
    • 0 tells Excel to find an exact match.
    Your formula now looks like: =INDEX(B2:E10, MATCH(G1, A2:A10, 0),.
  5. Create the Column MATCH: Now, add the second MATCH function to identify the column. Type MATCH(G2, B1:E1, 0).
    • G2 is the cell containing the value you are searching for in the columns.
    • B1:E1 is the range of the column headers.
    • 0 again ensures an exact match.
  6. Close the Formula: Add the final closing parenthesis and press Enter. The complete formula should look like this: =INDEX(B2:E10, MATCH(G1, A2:A10, 0), MATCH(G2, B1:E1, 0)).
  7. Test with Different Criteria: Change the values in cells G1 and G2. The result cell should automatically update to show the value at the intersection of the new row and column selections.

Common Mistakes

One of the most frequent errors is a mismatch in range sizes. For the INDEX function to work correctly, the row MATCH range must be the same height as the INDEX data range, and the column MATCH range must be the same width as the INDEX data range. If your data is in B2:E10 (9 rows, 4 columns), your row MATCH must cover exactly 9 cells (A2:A10) and your column MATCH must cover exactly 4 cells (B1:E1). If these are off by even one cell, Excel will return the wrong value or a #REF! error.

Another common mistake is forgetting the 0 at the end of the MATCH function. By default, if the match type is omitted, Excel assumes a 1 (approximate match), which requires the data to be sorted in ascending order. If your data is not sorted, an approximate match will likely return the wrong row or column. Always use 0 for exact lookups in business data.

Users also frequently include the headers inside the INDEX range. The INDEX range should only contain the values you want to return. If you include the headers in the INDEX range but not in the MATCH ranges, the formula will be shifted by one row or column, resulting in the value from the cell immediately adjacent to the one you actually wanted.

Tips

To make your lookup more robust, use Data Validation to create dropdown lists for your lookup criteria cells (G1 and G2). Go to the Data tab > Data Validation > Allow: List, and select your headers. This prevents typos from causing #N/A errors.

If you are using Office 365 or Excel 2021, you can use the XLOOKUP function for a more intuitive approach. You can nest one XLOOKUP inside another: =XLOOKUP(G1, A2:A10, XLOOKUP(G2, B1:E1, B2:E10)). This achieves the same result as INDEX/MATCH but is often easier to read and write because it doesn't require the match type 0.

For very large datasets, consider converting your data range into an official Excel Table (Ctrl + T). Using Table References (e.g., Table1[#Data]) instead of cell ranges (B2:E10) ensures that the lookup automatically expands when you add new rows or columns to your data, meaning you won't have to update your formulas manually.

Troubleshooting

If your formula returns #N/A, it means Excel cannot find the exact value you specified in either the row or column range. First, check for leading or trailing spaces in your lookup cells or your headers. A cell that looks like "January" but is actually "January " will not match. You can fix this by using the =TRIM() function on your data or lookup values.

If you see a #REF! error, it is almost certainly a range mismatch. Double-check that your INDEX range and your MATCH ranges are aligned. If your INDEX range starts at row 2, your row MATCH range must also start at row 2. If your INDEX range starts at column B, your column MATCH range must also start at column B.

If the formula returns the wrong value (but not an error), check the match type. Ensure every MATCH function ends with , 0). Also, verify that you haven't accidentally shifted your ranges (e.g., using A1:A10 for a match when the INDEX range is B2:E10).

If the result is 0 when you expect a value, check if the intersection cell in your matrix is actually empty. Excel treats empty cells as 0 in an INDEX function. You can wrap your formula in an IF statement or use a custom number format to hide zeros if necessary.

Frequently Asked Questions

Can I use VLOOKUP for this instead?

VLOOKUP is designed for single-column returns. To use it for multiple criteria (rows and columns), you would have to nest it inside a MATCH function to dynamically select the column index number. While possible, INDEX/MATCH is generally more flexible and faster for two-way lookups.

What if I have multiple criteria for the row only?

If you need to match two different row criteria (e.g., First Name AND Last Name) before finding the column, you can use an array formula or a helper column. The simplest way is to create a helper column that concatenates the two criteria (e.g., =A2&B2) and then perform your MATCH against that helper column.

Does this work with dates?

Yes, but dates must be formatted identically in both the lookup cell and the header row. If one is stored as text and the other as a date value, the MATCH function will fail. Ensure both are set to the same Date format.

Can I look up values across different sheets?

Absolutely. Simply click on the other sheet when selecting your ranges. The formula will look like =INDEX(Sheet2!B2:E10, MATCH(G1, Sheet2!A2:A10, 0), MATCH(G2, Sheet2!B1:E1, 0)).

Is INDEX/MATCH slower than XLOOKUP?

In extremely large workbooks with thousands of lookups, INDEX/MATCH can be slightly more efficient because you can reference the same MATCH result multiple times. However, for most users, the performance difference is negligible, and XLOOKUP is preferred for its simplicity.