Smart Systems for Home

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

Excel Table Lookup: Find Row and Column Values

· 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 at the intersection of a row and column in Excel, use the INDEX and MATCH functions together: =INDEX(data_range, MATCH(row_value, row_headers, 0), MATCH(column_value, column_headers, 0)). This returns the cell where the specified row and column meet, without needing to know the exact cell address. You can also use XLOOKUP if you have a newer Excel version, or a combination of VLOOKUP and MATCH for a simpler (but less flexible) approach. This guide walks through each method step by step, with examples.

What You'll Need

  • Microsoft Excel (any modern version; XLOOKUP requires Excel 365 or Excel 2021 and later).
  • A table of data with clear row headers (e.g., product names down the left) and column headers (e.g., months across the top).
  • Basic familiarity with cell references and formulas.

Step-by-Step

  1. Set up your data. Arrange your table so that the first column contains unique row labels (e.g., product IDs) and the first row contains unique column labels (e.g., quarter names). The intersection cells hold the values you want to retrieve. For example, A1 is blank, B1:D1 contain Q1, Q2, Q3; A2:A4 contain Product A, B, C; and B2:D4 contain sales figures.
  2. Decide on your lookup values. Pick the row label and column label you want to match. For instance, you might want the sales figure for Product B in Q2.
  3. Use INDEX and MATCH (works in all Excel versions). The formula structure is:
    =INDEX(data_range, MATCH(row_value, row_headers, 0), MATCH(column_value, column_headers, 0))
    In our example, if you want Product B and Q2, and your data range is B2:D4, row headers are A2:A4, column headers are B1:D1, the formula is:
    =INDEX(B2:D4, MATCH("Product B", A2:A4, 0), MATCH("Q2", B1:D1, 0))
    This returns the value at the intersection. The MATCH function with 0 finds an exact match; if no match is found, it returns #N/A.
  4. Use cell references instead of hard-coded text. For reusability, put the row label in one cell (e.g., G1) and the column label in another (e.g., G2), then reference them:
    =INDEX(B2:D4, MATCH(G1, A2:A4, 0), MATCH(G2, B1:D1, 0))
  5. Try XLOOKUP (Excel 365/2021+). XLOOKUP is simpler for two-way lookups. The syntax is:
    =XLOOKUP(row_value, row_headers, XLOOKUP(column_value, column_headers, data_range))
    For our example:
    =XLOOKUP("Product B", A2:A4, XLOOKUP("Q2", B1:D1, B2:D4))
    This nests one XLOOKUP inside another: the inner XLOOKUP returns the entire column for Q2, and the outer XLOOKUP picks the row for Product B. XLOOKUP defaults to exact match, so no fourth argument is needed.
  6. Alternative: VLOOKUP with MATCH. If you prefer VLOOKUP, you can use MATCH to find the column index dynamically:
    =VLOOKUP(row_value, table_range, MATCH(column_value, column_headers, 0), FALSE)
    Here, table_range must include the row headers as the first column. For example, if A1:D4 is the full table (with headers), and you want Product B and Q2:
    =VLOOKUP("Product B", A1:D4, MATCH("Q2", B1:D1, 0), FALSE)
    Note that MATCH returns the position within B1:D1 (1 for Q1, 2 for Q2, etc.), but VLOOKUP's column index counts from the first column of table_range (A). So you need to add 1 to the MATCH result if your table_range starts at column A and your column headers start at column B. In this example, MATCH("Q2", B1:D1, 0) returns 2, but Q2 is in column C, which is the 3rd column of A1:D4. So the correct formula is:
    =VLOOKUP("Product B", A1:D4, MATCH("Q2", B1:D1, 0)+1, FALSE)
  7. Test and adjust. Enter the formula in a cell and verify it returns the expected value. If you get #N/A, check that the lookup values exist exactly (no extra spaces, consistent case). If you get #REF!, ensure your ranges are correct.

Common Mistakes

  • Mismatched range sizes: The row_headers range must have the same number of rows as data_range, and column_headers must have the same number of columns. Otherwise, INDEX may return incorrect results or errors.
  • Forgetting the +1 in VLOOKUP+MATCH: As shown above, the column index from MATCH is relative to the column headers range, not the entire table. Adjust accordingly.
  • Using approximate match: Always use 0 (or FALSE) for exact match in MATCH and VLOOKUP unless you specifically need approximate matching (rare for text lookups).
  • Including headers in data_range: For INDEX, data_range should exclude headers. For VLOOKUP, the table_range must include the row headers as the first column.
  • Not locking ranges: If you copy the formula, use absolute references (e.g., $A$2:$A$4) for headers and data ranges to prevent them from shifting.

Tips

  • Use named ranges (Formulas > Define Name) to make formulas easier to read and maintain.
  • Convert your data to an Excel Table (Insert > Table) so ranges auto-expand when you add rows or columns.
  • For XLOOKUP, you can add an optional fourth argument (if_not_found) to display a custom message instead of #N/A, e.g., "Not found".
  • If you need to look up based on multiple criteria, consider using INDEX/MATCH with array formulas or the FILTER function (Excel 365).
  • Remember that XLOOKUP is not available in Excel 2019 or earlier; use INDEX/MATCH for compatibility.

Troubleshooting

  • #N/A error: The lookup value was not found. Check for typos, extra spaces (use TRIM), or mismatched data types (e.g., text vs. number). Ensure the lookup array contains the exact value.
  • #REF! error: The formula refers to an invalid cell reference. Verify that all ranges are correct and that you haven't deleted rows/columns that the formula depends on.
  • #VALUE! error: Often caused by incorrect argument types. Make sure MATCH is returning a number and that INDEX arguments are valid.
  • Wrong result: Double-check that the row and column headers are aligned with the data. Also, ensure you are using exact match (0) in MATCH.
  • Formula not updating: If calculation is set to manual, press F9 to recalculate, or set calculation to automatic in Formulas > Calculation Options.
  • XLOOKUP not available: If you type =XLOOKUP and Excel doesn't recognize it, your version doesn't support it. Use INDEX/MATCH instead.

Frequently Asked Questions

Can I use INDEX and MATCH to look up a value based on both row and column headers?

Yes, that's exactly what the combination does. INDEX retrieves the value at the intersection of a specified row and column number, and MATCH finds those numbers based on your lookup values.

What is the difference between VLOOKUP and INDEX/MATCH for two-way lookups?

VLOOKUP can only look to the right of the lookup column, and it requires a helper to find the column index. INDEX/MATCH is more flexible because it can look in any direction and doesn't require the lookup column to be first. XLOOKUP is the modern replacement for both.

Can I use XLOOKUP for a two-way lookup?

Yes, by nesting one XLOOKUP inside another: the inner XLOOKUP returns the entire column for the column criteria, and the outer XLOOKUP picks the row. This works in Excel 365 and Excel 2021+.

Why do I get #N/A even though the value exists?

Common causes: trailing spaces, numbers stored as text, or case differences. Use TRIM and check cell formatting. Also ensure you are using exact match (0) in MATCH.

Can I look up a value using row and column numbers instead of labels?

Yes, you can use INDEX directly with row and column numbers: =INDEX(data_range, row_num, column_num). For example, =INDEX(B2:D4, 2, 3) returns the value in the 2nd row and 3rd column of B2:D4.

Is there a way to do a two-way lookup with a single formula without nesting?

Not with standard functions, but you can use SUMPRODUCT with boolean logic for numeric data, though it's less efficient and only works for numbers. INDEX/MATCH or XLOOKUP are the recommended approaches.