Excel Everest

View Original

How to Use Excel's INDEX and MATCH Functions Together

In the world of Microsoft Excel, there are countless functions that can help you to manage and analyze data. Two such functions are INDEX and MATCH. When used together, these functions can prove to be incredibly powerful tools. They can help you to look up data from a table or a range, offering a more versatile and dynamic approach compared to the commonly used VLOOKUP and HLOOKUP functions.

In this blog post, we will explore how to use Excel's INDEX and MATCH functions together. By the end of this guide, you will have a solid understanding of how these functions work, and you will be able to apply them in various situations to improve your data management skills.

Overview of INDEX and MATCH Functions

Before we dive into how to use these functions together, let's first understand what each function does individually.

1. INDEX Function

The INDEX function in Excel returns the value of a cell within a specified range, based on the row and column number you provide. Its syntax is as follows:

=INDEX(array, row_num, column_num)

  • array: The range of cells from which you want to retrieve a value.

  • row_num: The row number within the array from which you want to retrieve a value.

  • column_num: The column number within the array from which you want to retrieve a value.

    2. MATCH Function

    The MATCH function searches for a specified value within a range and returns the relative position of that value. Its syntax is as follows:

    =MATCH(lookup_value, lookup_array, [match_type])

  • lookup_value: The value you want to search for in the lookup_array.

  • lookup_array: The range of cells containing the values you want to search.

  • match_type: Optional. Indicates the type of match you want to perform:

  • 1: Finds the largest value less than or equal to the lookup_value (lookup_array must be sorted in ascending order).

  • 0: Finds the first value exactly equal to the lookup_value (lookup_array does not need to be sorted).

  • -1: Finds the smallest value greater than or equal to the lookup_value (lookup_array must be sorted in descending order).

    Using INDEX and MATCH Functions Together

    Now that we understand the basic functionality of each function, let's see how we can use them together. When combined, the INDEX and MATCH functions can look up a value based on both row and column criteria, which makes them a more flexible alternative to VLOOKUP and HLOOKUP.

    The syntax for using INDEX and MATCH together is as follows:

    =INDEX(return_array, MATCH(row_lookup_value, row_lookup_array, match_type), MATCH(column_lookup_value, column_lookup_array, match_type))

    Example

    Let's go through an example to better understand how to use the INDEX and MATCH functions together. Imagine we have the following table of data:

We want to find the score of a student whose name is Jane and age is 30. Here's how we can achieve this using the INDEX and MATCH functions:

Step 1: Identify the return_array, row_lookup_array, and column_lookup_array

  • return_array: The range containing the values you want to return. In this case, it's the "Score" column (D2:D5).

  • row_lookup_array: The range containing the row criteria. In this case, it's the "Name" column (A2:A5).

  • column_lookup_array

    keep going

    : The range containing the column criteria. In this case, it's the "Age" column (B2:B5).

    Step 2: Use the INDEX and MATCH functions together

    Now that we have identified the necessary arrays, we can use the following formula to find Jane's score:

    =INDEX(D2:D5, MATCH("Jane", A2:A5, 0), MATCH(30, B2:B5, 0))

    Here's a breakdown of the formula:

    1. MATCH("Jane", A2:A5, 0): This function looks for the exact value "Jane" in the range A2:A5 and returns its relative position. In this case, the relative position is 2.

    2. MATCH(30, B2:B5, 0): This function looks for the exact value 30 in the range B2:B5 and returns its relative position. In this case, the relative position is also 2.

    3. INDEX(D2:D5, 2, 2): This function returns the value in the second row and second column of the range D2:D5, which is 78.

    So, the formula returns Jane's score as 78.

    Additional Tips for Using INDEX and MATCH Together

    1. Use Named Ranges: To make your formulas more readable, consider using named ranges instead of cell references. For example, you can name the ranges as follows: Names = A2:A5, Ages = B2:B5, Scores = D2:D5. Then, the formula becomes =INDEX(Scores, MATCH("Jane", Names, 0), MATCH(30, Ages, 0)).

    2. Handle Errors: You can use the IFERROR function to handle any errors that might occur when using the INDEX and MATCH functions together. For example, if the name or age you're looking for is not found in the table, the formula will return an error. You can use the following formula to return a custom message instead: =IFERROR(INDEX(Scores, MATCH("Jane", Names, 0), MATCH(30, Ages, 0)), "Not found").

    3. Perform Case-Insensitive Searches: By default, the MATCH function is case-sensitive. If you want to perform a case-insensitive search, you can use the EXACT function along with an array formula. For example, you can use the following formula to find the score for "jane" (with a lowercase 'j'): =INDEX(Scores, MATCH(TRUE, EXACT("jane", Names), 0), MATCH(30, Ages, 0)). Note that you'll need to enter this formula as an array formula by pressing Ctrl + Shift + Enter.

    Conclusion

    In this blog post, we've learned how to use Excel's INDEX and MATCH functions together to perform flexible lookups based on both row and column criteria. This powerful combination can help you to manage and analyze data more effectively, and it offers a more versatile and dynamic approach compared to VLOOKUP and HLOOKUP. So, the next time you need to perform a lookup in Excel, give INDEX and MATCH a try!