Yes, you can replace VLOOKUP with INDEX and MATCH. It is a two-step lookup function that finds a value based on its position in a column and its position in a row, allowing you to search in any direction and return data from any column, not just the one to the right.
What You'll Need
- A computer with Microsoft Excel installed. This guide uses the desktop version of Excel for Windows, but the logic is identical in Excel for Mac.
- Two sets of data: a lookup column (e.g., a list of names or product codes) and a result column (e.g., prices, addresses, or dates).
- Basic familiarity with referencing cells (e.g., A1, B2) and typing formulas.
Step-by-Step
The INDEX and MATCH combination works in two parts: MATCH locates the row or column you want, and INDEX returns the value at that location. You can use them together or separately.
Part 1: Understanding MATCH
MATCH searches for a specific item in a range and returns its relative position. It is a one-way search. If you have a list of names in cells C2 to C10, and you want to find the position of "John Doe" in that list, MATCH will return the number 5 if John is the fifth name in the list. The syntax is =MATCH(lookup_value, lookup_array, [match_type]).
Part 2: Understanding INDEX
INDEX returns a value from a specific location in an array. It does not search; it simply retrieves data based on a row and column number. The syntax is =INDEX(array, row_num, [column_num]). If you want the value in the fifth row and second column of a range, INDEX returns that specific cell's content.
Part 3: Combining INDEX and MATCH
Here is how to build a formula that finds a value in a column to the left of your search criteria. Imagine you have a table where column A contains Employee Names and column B contains their Phone Numbers. You want to find the phone number for a specific employee entered in cell F1.
- Decide the direction of the search. In this example, the data is to the left, so you will use MATCH to find the row number of the employee, and INDEX to retrieve the phone number from that row.
- Build the MATCH part. Click on the cell where you want the result to appear. Type
=MATCH(. The first argument is the value you are looking for. Select the cell containing the employee name (e.g., F1). Type a comma. The second argument is the range that Excel should look through. Select the entire column of names (e.g., A2:A10). Type a comma. The third argument determines how Excel finds the match. For an exact match, type0. Close the parenthesis. Your formula should look like this:=MATCH(F1, A2:A10, 0). - Build the INDEX part. Type a comma to separate the two functions. Start typing
=INDEX(. The first argument is the array from which you want to retrieve a value. Select the entire column of phone numbers (e.g., B2:B10). Type a comma. The second argument is the row number. You need to insert the MATCH function here. Click inside the parentheses of the MATCH function you just typed. Your formula should now look like=INDEX(B2:B10, MATCH(F1, A2:A10, 0)). - Close the formula. Type a closing parenthesis
)to end the INDEX function. Press Enter. - Verify the result. If the name in F1 exists in your list, the correct phone number will appear. If the name is not found, Excel will return
#N/A.
Part 4: Searching in Any Direction
The power of INDEX and MATCH is that they are not limited to looking to the right. You can search up, down, left, or right. To find the price of a product where the price is in a column to the left of the product name, you would swap the order of the arguments for INDEX.
- Set up your data. Let's say column B contains Product Names and column A contains Prices.
- Construct the formula. The MATCH function remains the same: it still finds the row number of the product name.
=MATCH("Widget", B2:B10, 0). Let's assume this returns the number 3. - Modify INDEX. Instead of fetching the value from the column to the right, you need to fetch it from the column to the left. The INDEX function syntax is
=INDEX(array, row_num). The array is the column of prices (A2:A10). The row_num is the result of the MATCH function. The full formula is=INDEX(A2:A10, MATCH("Widget", B2:B10, 0)).
Common Mistakes
Even experienced users make mistakes with INDEX and MATCH. The most frequent error is confusing the order of the arguments, especially when searching left. Remember that MATCH always looks through the second argument, and INDEX always pulls from the first argument. If you are searching for a value in the first column, MATCH must use that column, and INDEX must use the column you want to retrieve data from.
Another common mistake is failing to use the 0 match type in MATCH. Using 1 or -1 tells Excel to find the closest match, which can return incorrect results if your data is not sorted. Always use 0 for exact matches.
Finally, users often forget to lock the ranges. If you copy the formula down, the ranges will shift. To lock a range so it does not move, use absolute references. Add a dollar sign before the column letter and row number (e.g., $A$2:$A$10). This ensures that Excel always searches the entire list of names, regardless of which cell the formula is pasted into.
Tips
When building complex formulas, it is often helpful to break them into smaller parts. First, calculate the MATCH result in a separate cell to verify it is finding the correct row number. Only combine it with INDEX once you know the MATCH function is working correctly.
Use the IFERROR function to handle cases where a match is not found. Wrap your INDEX and MATCH formula in IFERROR(YourFormula, "Not Found"). This will display a friendly message instead of an error code.
For very large datasets, INDEX and MATCH are generally faster than VLOOKUP, but they can still be slow if the ranges are excessively large. Try to limit your ranges to only the data you need, rather than selecting entire columns like A:A or B:B.
Troubleshooting
If your formula returns #N/A, it means Excel cannot find the lookup value in the lookup array. First, check for typos or extra spaces. The name in cell F1 might be "John Doe" but the list might have "John Doe" with a double space. Use the TRIM function to remove leading, trailing, or multiple spaces between words: =TRIM(F1).
If the data looks identical but still returns #N/A, check for hidden characters or formatting issues. Sometimes numbers are formatted as text, or dates are in different formats. Copy a valid item from your list and paste it into the lookup cell to compare the formatting.
If the formula returns an incorrect value, it is usually because of the match type argument. Ensure you typed 0 for an exact match. If you are searching for a number, make sure the lookup value is not formatted as text. You can use the VALUE function to convert text to a number: =VALUE(F1).
If the result is a #REF! error, you likely have an issue with the range references. This can happen if you deleted rows or columns from your table. Check that the MATCH and INDEX functions are referencing the correct remaining ranges.
Frequently Asked Questions
Why should I use INDEX and MATCH instead of VLOOKUP?
INDEX and MATCH are more flexible because they can look to the left, right, or up, while VLOOKUP can only look to the right. Additionally, INDEX and MATCH are more efficient with large spreadsheets and do not break if you insert new columns between your lookup and return columns.
How do I use INDEX and MATCH if I have multiple criteria?
INDEX and MATCH can be combined with the SUMPRODUCT function or the FILTER function (in newer versions of Excel) to search for multiple criteria. For example, you can multiply two MATCH arrays together to find a row that meets both conditions.
What is the difference between MATCH and LOOKUP?
MATCH is a function that only returns the position of a value in a list. LOOKUP is a legacy function that finds a value in a single row or column and returns a corresponding value from a second row or column, similar to VLOOKUP but less flexible.
Why does my MATCH formula return #N/A?
This means the lookup value is not found in the lookup array. Check for typos, mismatched data types (text vs. number), or extra spaces. Ensure the match type is set to 0 for an exact match.
Can I use INDEX and MATCH with a date range?
Yes, INDEX and MATCH work perfectly with dates. You can match a specific date or even use a date range to find a value between two dates. Just ensure the dates in your lookup array and lookup value are in the same format.