You can combine Excel’s INDEX and MATCH functions in a single formula to pull data from a lookup table based on two criteria, creating a flexible template that works even when data is not sorted. This technique replaces the older VLOOKUP and provides more control over column selection and error handling.

What You'll Need

  • A computer with Microsoft Excel installed (2021, 365, or Excel for the Web). The functions work identically across these platforms, though the interface for creating a new workbook is slightly different on mobile devices.
  • A spreadsheet with at least two distinct sets of data. You need a main dataset (the source) and a criteria list (where the user enters search terms). The template structure requires the criteria to be on the left side of your main data table.
  • Basic familiarity with cell referencing (A1, B2, etc.) and the concept of absolute references (using the dollar sign, like $A$1). If you do not know how to lock a cell reference, the template will not copy correctly.

Step-by-Step

Follow these steps to build a template that searches for a Year and a Category to return a specific Value. Imagine your data is organized in columns A through D, with headers in the first row.

  1. Create the Criteria Section. Set up a small area on your sheet to input the search terms. In cell G1, type the year you want to find (e.g., 2023). In cell G2, type the category (e.g., Electronics). These cells will be the input points for your template.
  2. Build the Lookup Table. Ensure your source data is in a standard tabular format. The first column must contain the primary criteria (the Year), followed by the secondary criteria (the Category), and finally the data you want to retrieve (the Value). Ensure there are no blank rows within this block of data.
  3. Enter the MATCH Function. Click on the cell where you want the result to appear. Type =MATCH( to start the function. For the first argument, select the cell containing the first criteria (G1). For the second argument, select the column containing that criteria in your data table (e.g., column A). For the third argument, type 0 to force an exact match. Press Enter. This function returns the row number where the year matches.
  4. Enter the INDEX Function. With the result cell selected, type =INDEX(. The first argument is the entire data table range (e.g., A1:D100). The second argument is the result from the MATCH function you just created (e.g., the result of the previous formula). The third argument is the column number containing the data you want to retrieve (e.g., column C for the Value). Close the parenthesis and press Enter.
  5. Apply Absolute Referencing. Click on the cell containing your formula. In the formula bar, ensure the range for the INDEX function (e.g., A1:D100) has dollar signs around it so it does not shift when you copy the formula to other rows or columns. The relative references for the criteria (G1, G2) should not have dollar signs.
  6. Copy the Template. Drag the fill handle (the small square at the bottom right of the cell) to copy the formula to other cells in your template. Change the values in G1 and G2 to test different combinations. The formula should dynamically update the result based on the criteria.

Common Mistakes

Several specific errors prevent the Index Match template from working correctly. Identifying these early saves time and frustration.

  • Incorrect MATCH Type. Forgetting to type 0 as the third argument in the MATCH function is the most common error. If you leave this out, Excel defaults to 1, which finds the closest value in a sorted list. This will rarely return the correct row and often results in an error if the data is not sorted.
  • Non-Contiguous Columns. Trying to use INDEX to select a value from a column that is not adjacent to the criteria columns is a frequent issue. For example, selecting a value from column E when your criteria are in columns A and B requires a specific array construction that is far more complex than the standard template. Keep your data structured in adjacent columns for a simple template.
  • Unsorted Data. While the standard INDEX/MATCH combination does not strictly require data to be sorted, the MATCH function with the 1 type does. If you accidentally use 1 or -1 and your data is not sorted, Excel will return a #N/A error or a wrong number, making it seem like the formula is broken.
  • Hardcoding Cell References. Writing the row number from the MATCH function directly into the INDEX function (e.g., =INDEX(A1:D100, 5, 3)) defeats the purpose of the template. This makes the formula static; it will only work for that one specific row and cannot be copied or used for other search terms.

Tips

  • Use Named Ranges. Instead of typing the range A1:D100 repeatedly, select that range and give it a name like DataTable. Your formula becomes =INDEX(DataTable, MATCH(G1, INDEX(DataTable,0,1),0), 3). This makes the formula much easier to read and maintain, especially for large datasets.
  • Check for Hidden Characters. If your MATCH function returns #N/A even when the data looks identical, copy the criteria from your input cell and paste it into the criteria column in your data table. Compare them character by character. Often, a space at the end of a text string or a different line break character causes a mismatch that is invisible to the naked eye.
  • Combine with IFERROR. Wrap the entire formula in an IFERROR function to handle cases where no match is found. For example, =IFERROR(INDEX(...), "Not Found"). This prevents the #N/A error from displaying and provides a clear message to the user of your template.
  • Order of Arguments. Remember the syntax order for INDEX is INDEX(array, row_num, [column_num]). The row number comes first, followed by the column number. Reversing these will return a value from the wrong column.

Troubleshooting

When the formula does not work, proceed through these checks in order to isolate the issue.

  1. Verify the Data Types. Ensure that the value in your criteria cell (G1) matches the data type in the criteria column of your table. If you are searching for a number, the criteria cell should be formatted as a number, not text. If you are searching for text, ensure there are no leading or trailing spaces. You can use the TRIM() function on the criteria column to clean the data.
  2. Check the MATCH Range. Ensure that the range selected for the MATCH function corresponds exactly to the column where the criteria exist. If you select column A for the match but the data is actually in column B, the function will return #N/A. The MATCH range must be a single column containing the lookup values.
  3. Inspect the Formula Syntax. Look closely at the opening and closing parentheses. A missing parenthesis is the most common cause of a generic #VALUE! error. Excel will usually highlight the misplaced parenthesis in red, making it easy to spot.
  4. Confirm Absolute Referencing. If copying the formula results in incorrect data, the ranges used in the INDEX function are likely not locked. Ensure that the data table range has dollar signs on both the column and row references (e.g., $A$1:$D$100). The criteria cells should remain relative.
  5. Use the Evaluate Formula Tool. If the formula is complex and still failing, use the Formulas tab in the ribbon. Select the formula cell and click Evaluate Formula. This tool walks you through the calculation step-by-step, showing the result of each part of the function. This is the best way to debug exactly where the logic is breaking down.

Frequently Asked Questions

Why does my Index Match formula return #N/A?

This is the most common issue. It almost always means that the criteria in your input cell does not exist exactly as written in your data table. Check for spelling errors, hidden spaces, or mismatched data types (text vs. number).

Can I use Index Match with three criteria?

Yes, but the formula becomes more complex. You must multiply the results of the MATCH functions. The syntax is =INDEX(return_range, MATCH(criteria1, criteria1_range, 0) * MATCH(criteria2, criteria2_range, 0)). This forces Excel to find a row that satisfies both conditions simultaneously.

Is Index Match faster than VLOOKUP?

For small datasets, the difference is negligible. However, for very large datasets (hundreds of thousands of rows), INDEX/MATCH is generally faster and more memory efficient because it does not scan the entire column like VLOOKUP does.

Why does my formula return a value from the wrong row?

This is usually caused by incorrect absolute referencing. If the row number in your INDEX function is not locked (e.g., it is just a number like 5), Excel will treat it as a relative position, which changes when you copy the formula down. The MATCH function must return the correct row number for the data to be accurate.

What is the difference between INDEX and MATCH?

INDEX returns the value at a specific intersection of a row and column within a range. MATCH returns the relative position of an item in a range that matches a specified value. Together, they allow you to look up a value in a column and then retrieve a value from a different column in the same row.