INDEX MATCH – Excel & Google Sheets

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on February 7, 2023
Download Example Workbook

Download the example workbook

This tutorial will teach you how to use the INDEX & MATCH combination to perform lookups in Excel and Google Sheets.

index match main func

INDEX & MATCH, The Perfect Pair

Let’s take a closer look at some of the ways you can combine the INDEX and MATCH functions. The MATCH function is designed to return the relative position of an item within an array, while the INDEX function can fetch an item from an array given a specific position. This synergy between the two allows them to perform almost any type of lookup you might need.

The INDEX / MATCH combination has historically been used as a replacement to the VLOOKUP Function. One of the primary reasons being the ability to do a left-looking lookup (see next section).

Note: the new XLOOKUP Function can now perform left-looking lookups.

Lookup to the Left

Let’s use this table of basketball stats:

Lookup Table

We want to find Bob’s Player #. Because the Player # is to the left of the name column, we can’t use a VLOOKUP.

Instead, we could do a basic MATCH request to calculate Bob’s row

=MATCH(H2, B2:B5, 0)

This will look for an exact match of the word “Bob”, and so our function would return the number 2, since “Bob” is in the 2nd position.

Next we can use the INDEX Function to return the Player #, corresponding to a row. For now, let’s just manually enter “2” into the function:

=INDEX(A2:A5, 2)

Here, INDEX will reference A3, since that’s the 2nd cell within the A2:A5 range and return the result of 42. For our overall goal, we can then combine these two into:

=INDEX(A2:A5, MATCH(H2, B2:B5, 0))

Lookup

The benefit here is that we were able to return a result from a column to the left of where we were searching.

Two-dimension lookup

Let’s look at our table from before:

Lookup Table

This time however, we want to fetch a specific statistic. We’ve called out that we want to search for Rebounds in cell H1. Rather than having to write several IF statements to determine which column to get the result from, you can use a MATCH function again. The INDEX function lets you specify the row value and the column value. We’re going to add another MATCH function here to determine which column we want. That will look like

=MATCH(H1, A1:E1, 0)

Our cell in H1 is a dropdown that let’s us choose what category we want to search for, and then our MATCH determines which column in the table that belongs to. Let’s plug this new bit into our previous formula. Note that we need to tweak the first argument to be two dimensions, as we no longer just want a result from column A.

=INDEX(A2:E5, MATCH(H2, B2:B5, 0), MATCH(H1, A1:E1, 0))

Two dimension

In our example, we want to find Rebounds for Charlie. Our formula is going to evaluate this like so:

=INDEX(A2:E5, MATCH("Charlie", B2:B5, 0), MATCH("Rebounds", A1:E1, 0))
=INDEX(A2:E5, 3, 4)
=D4
=6

We’ve now created a flexible setup that allows the user to fetch any value they want from our table without having to write multiple formulas or branching IF statements.

Multiple sections

It’s not often used, but INDEX has a fifth argument that can be given to determine which area within argument one to use. This means that we need a way to pass multiple areas into the first argument. You can do this by using an extra set of parentheses. This example will illustrate how you could fetch results from different tables on a worksheet using INDEX.

Here’s the layout we’ll be using. We’ve got statistics for three different quarters of play.

Multiple Sections Table

In cells H1:H3, we’ve created Data Validation drop down lists for our various choices. The dropdown for the Quarter is coming from J2:J4. We’ll use this for another MATCH statement, to determine which area to use. Our formula in H4 is going to look like this:

=INDEX((A3:E6, A10:E13, A17:E20), MATCH(H2, B3:B6, 0), MATCH(H1, A2:E2, 0), MATCH(H3, J2:J4, 0))

We’ve already discussed how the inner two MATCH functions work, so let’s focus on the first and last arguments:

=INDEX((A3:E6, A10:E13, A17:E20), …, MATCH(H3, J2:J4, 0))

We’ve given the INDEX function multiple arrays in the first argument by enclosing them all within parentheses. The other way you could do this is by using Formulas – Define Name. You could define a name called “MyTables” with a definition of:

='Multiple Sections'!$A$3:$E$6;'Multiple Sections'!$A$10:$E$13;'Multiple Sections'!$A$17:$E$20

This way, we are getting the follwing formula:

=INDEX(MyTable,MATCH(H2,Table1347[Name],0),MATCH(H1,Table1347[#Headers],0),MATCH(H3,J2:J4,0))

Multiple Sections

Let’s go back to the whole statement. Our various MATCH functions are going to tell the INDEX function exactly where to look. First, we’ll determine that “Charlie” is the 3rd row. Next, we want “Rebounds”, which is the 4th column. Finally, we’ve determined that we want the result from 2nd table. The formula will evaluate through this like so:

=INDEX((A3:E6, A10:E13, A17:E20), MATCH(H2, B3:B6, 0), MATCH(H1, A2:E2, 0), MATCH(H3, J2:J4, 0))
=INDEX((A3:E6, A10:E13, A17:E20), 3, 4, 2)
=INDEX(A10:E13, 3, 4)
=D13
=14

As we mentioned at the beginning of this example, you’re limited to having the tables be on the same worksheet. If you can write out correct ways to tell your INDEX which row, column, and/or area you want to retrieve data from, INDEX will serve you very well.

Google Sheets –INDEX & MATCH

All of the above examples work exactly the same in Google Sheets as in Excel.

INDEX MATCH GSheet

AI Formula Generator

Try for Free

Excel Practice Worksheet

practice excel worksheet

Practice Excel functions and formulas with our 100% free practice worksheets!

  • Automatically Graded Exercises
  • Learn Excel, Inside Excel!

Free Download

Return to Excel Formulas List