Excel in this position

Содержание

  1. Use the MATCH function in Excel to find the position of a value in a list
  2. MATCH() Function Syntax
  3. Crucial — understanding the match_type parameter
  4. Using the MATCH function in Excel — find a match in a list without duplicates
  5. The MATCH function in action — finding a match in a list with duplicates
  6. Using MATCH in an unsorted list that contains duplicate values
  7. Using MATCH in an list sorted in ascending order with duplicate values
  8. Using MATCH in an list sorted in descending order with duplicate values
  9. Summary of the MATCH function
  10. INDEX & MATCH Functions Combo in Excel (10 Easy Examples)
  11. INDEX Function: Finds the Value-Based on Coordinates
  12. MATCH Function: Finds the Position baed on a Lookup Value
  13. Understanding Match Type Argument in MATCH Function
  14. Let’s Combine Them to Create a Powerhouse (INDEX + MATCH)
  15. Example 1: A simple Lookup Using INDEX MATCH Combo
  16. Example 2: Lookup to the Left
  17. Example 3: Two Way Lookup
  18. Example 4: Lookup Value From Multiple Column/Criteria
  19. Example 5: Get Values from Entire Row/Column
  20. Example 6: Find the Student’s Grade (Approximate Match Technique)
  21. Example 7: Case Sensitive Lookups
  22. Example 8: Find the Closest Match
  23. Example 9: Use INDEX MATCH with Wildcard Characters
  24. Example 10: Three Way Lookup
  25. Why is INDEX/MATCH Better than VLOOKUP?
  26. INDEX/MATCH can look to the Left (as well as to the right) of the lookup value
  27. INDEX/MATCH can work with vertical and horizontal ranges
  28. VLOOKUP cannot work with descending data
  29. INDEX/MATCH can be slightly faster
  30. INDEX/MATCH is Independent of the Actual Column Position
  31. VLOOKUP is easier to use

Use the MATCH function in Excel to find the position of a value in a list

The MATCH() function allows you to find the relative position of a value in a list in Excel. For example, in a list of weekdays starting with Monday first, MATCH() would return a value of 3 for Wednesday. This lesson explains how to use the MATCH() function in Microsoft Excel, explains where you might use it, and provides a real world example of the MATCH() function in action.

MATCH() Function Syntax

The MATCH() function has the following syntax:

=MATCH(lookup_value,lookup_array,match_type)

  • lookup_value is the value you want to find in the list. It is required for the function to work.
  • lookup_array is the range of cells that contain the list. It is required for the function to work.
  • match_type is an optional value that defines the type of match you are looking for. It can have three possible values, -1, 0 and 1. If you leave it out Excel assumes a value of 1.

The MATCH function finds the position of your lookup_value in the range of cells you’re looking in (the lookup_array). It’s important to note that if your list doesn’t include the lookup_value, the MATCH function will return a #NA error.

Crucial — understanding the match_type parameter

Understanding the match_type parameter is the key to using the MATCH function effectively.

Although match_type is optional, I recommend you always set it to the correct value when using the MATCH function. Otherwise your MATCH functions won’t always return the results you expect.

  • A match_type value of 1 should be used when your list is sorted in ascending order (smallest to largest).
    • If your list contains your lookup_value more than once, MATCH will return the position of the last instance of that value.
    • If your list is not sorted you will sometimes get the right answer, but sometimes you’ll get a #N/A error.
    • If your list doesn’t contain your lookup_value, MATCH will return the position of the next largest value.
    • If you don’t supply a match_type, Excel will automatically use 1 as the match_type.
  • A match_type value of 0 means your list doesn’t need to be sorted.
    • MATCH will look for an exact match for your lookup_value in the list
    • MATCH will return the position of the first occurrence of the lookup_value it finds, even if there are duplicates in the list
    • Important — MATCH will return a #N/A error if the lookup_value is not in the list.
  • A match_type value of -1 should be used when your list is sorted in descending order (largest to smallest).
    • If your list is not sorted you will sometimes get the right answer, but sometimes you’ll get a #N/A error.
    • If your list contains your lookup_value more than once, MATCH will return the position of the last instance in the list of that value.
    • If your list doesn’t contain your lookup_value, MATCH will return the position of the next smallest value.

Using the MATCH function in Excel — find a match in a list without duplicates

This example looks at how to use the MATCH function if your list doesn’t contain any duplicates.

  • The data for this example is a list of people’s names. The list is not sorted alphabetically.
  • We want to find where a particular person appears in the list. In this case, we know each person only appears once.
  • In this situation, you should set match_type to 0. If you don’t, Excel will set match_type to 1, and your formula is likely to return the wrong result.
  • You enter the MATCH function into your spreadsheet as follows:
  • In the example above, B12 contains the MATCH function, which returns a value of 5 since Ramit is 4th in the list.
    • Note that you will get a #N/A result if you enter a name into B11 that doesn’t exist in the list.
  • B13 shows us the MATCH function as it was entered:
    • The value to find a match for is in B11. We could also have entered Ramit into the MATCH function direcly as the lookup value rather than referencing B11.
    • The range of cells to look up is A3:A9, i.e. the cells containing our list of names.
    • We have set the match_type parameter to 0 because each name appears only once.

The MATCH function in action — finding a match in a list with duplicates

MATCH gets more complicated when you have lists that contain duplicate values since MATCH can only return one value. In other words, even if you have the value you are looking for appears 3 times, MATCH can only give you the position of one of those values.

Using MATCH in an unsorted list that contains duplicate values

  • If your list contains duplicates but is not sorted, the most reliable way to use MATCH is to set match_type to 0.
    • This will return the position of the first instance of match_type on your list.
    • Also, it will only return a result if there is an exact match. Setting match_type to 1 or -1 when your list is not sorted will return unpredictable and sometimes incorrect results.
  • In this example, we have list of numbers that is not sorted and contains duplicate values. We want to find the position of a certain number on that list
  • In the example above, we are looking for the position of 52 in the list. As you can see, 52 is repeated three times in the list.
  • The position returned by the MATCH function in this example is 6 because this is the first instance of 52 that MATCH encountered (when starting from the list and working down). The other two values are ignored by the MATCH function.
  • This is a very important fact to remember. MATCH can only find one instance of a value in a list. It will not let you look specifically for the second or third instances of a value in a list.

Using MATCH in an list sorted in ascending order with duplicate values

  • If your list is sorted in ascending order, you should set match_type to 1.
    • You can also leave the match_type value out altogether, since Excel will assume a value for 1 if match_type is not present.
  • The following example uses the same set of numbers as the previous example:
  • In this example, note that the list is sorted and that 52 occupies positions 5, 6 and 7 in the list.
  • The MATCH function, with match_type set to 1, has returned 7. This is because the last instance of 52 on the list is in position 7.
  • Once again, remember that MATCH can only return one value from the list.
    • If you want MATCH to return the position of the first instance of 52, you could set match_type to 0.
    • There is no reliable way to get MATCH to return the position of the second instance of 52 in the list.

Using MATCH in an list sorted in descending order with duplicate values

  • If your list is sorted in descending order, you should set match_type to -1.
  • The following example uses the same set of numbers as the previous two examples:
  • In this example, note that the list is sorted and that 52 occupies positions 5, 6 and 7 in the list.
  • The MATCH function, with match_type set to -1, has returned 7. As with the previous example, this is because the last instance of 52 on the list is in position 7.
  • Once again, remember that MATCH can only return one value from the list.
    • If you want MATCH to return the position of the first instance of 52, you could set match_type to 0.
    • There is no reliable way to get MATCH to return the position of the second instance of 52 in the list.

Summary of the MATCH function

MATCH performs a very specific and somewhat limited function in Excel. If you are planning to use MATCH in your spreadsheets, make sure you understand the job that match_type does in determining how the MATCH function will decide what result to return. It is also a good idea to include match_type when you use the MATCH function even if you don’t need to. That avoids mistakes, and makes troubleshooting easier.

Источник

INDEX & MATCH Functions Combo in Excel (10 Easy Examples)

Excel has a lot of functions – about 450+ of them.

And many of these are simply awesome. The amount of work you can get done with a few formulas still surprises me (even after having used Excel for 10+ years).

And among all these amazing functions, the INDEX MATCH functions combo stands out.

This Tutorial Covers:

I am a huge fan of INDEX MATCH combo and I have made it pretty clear many times.

I even wrote an article about Index Match Vs VLOOKUP which sparked a little bit of debate (you can check the comments section for some firework).

And today, I am writing this article solely focussed on Index Match to show you some simple and advanced scenarios where you can use this powerful formula combo and get the work done.

Now before I show you how the combination of INDEX MATCH is changing the world of analysts and data scientists, let me first introduce you to the individual parts – INDEX and MATCH functions.

INDEX Function: Finds the Value-Based on Coordinates

The easiest way to understand how Index function works is by thinking of it as a GPS satellite.

As soon as you tell the satellite the latitude and longitude coordinates, it will know exactly where to go and find that location.

So despite having a mind-boggling number of lat-long combinations, the satellite would know exactly where to look.

I quickly did a search for my work location and this is what I got.

Anyway, enough of geography.

Just like a satellite needs latitude and longitude coordinates, the INDEX function in Excel would need the row and column number to know what cell you’re referring to.

And that’s Excel INDEX function in a nut-shell.

So let me define it in simple words for you.

The INDEX function will use the row number and column number to find a cell in the given range and return the value in it.

All by itself, INDEX is a very simple function, with no utility. After all, in most cases, you are not likely to know the row and column numbers.

The fact that you can use it with other functions (hint: MATCH) that can find the row number and the column number makes INDEX an extremely powerful Excel function.

Below is the syntax of the INDEX function:

  • array – a range of cells or an array constant.
  • row_num – the row number from which the value is to be fetched.
  • [col_num] – the column number from which the value is to be fetched. Although this is an optional argument, but if row_num is not provided, it needs to be given.
  • [area_num] – (Optional) If array argument is made up of multiple ranges, this number would be used to select the reference from all the ranges.

INDEX function has 2 syntaxes (just FYI).

The first one is used in most cases. The second one is used in advanced cases only (such as doing a three-way lookup) which we will cover in one of the examples later in this tutorial.

But if you’re new to this function, just remember the first syntax.

Below is a video that explains how to use the INDEX function

MATCH Function: Finds the Position baed on a Lookup Value

Going back to my previous example of longitude and latitude, MATCH is the function that can find these positions (in the Excel spreadsheet world).

In simple language, the Excel MATCH function can find the position of a cell in a range.

And on what basis would it find a cell’s position?

Based on the lookup value.

For example, if you have a list as shown below and you want to find the position of the name ‘Mark’ in it, then you can use the MATCH function.

The function returns 3, as that’s the position of the cell with the name Mark in it.

MATCH function starts looking from top to bottom for the lookup value (which is ‘Mark’) in the specified range (which is A1:A9 in this example). As soon as it finds the name, it returns the position in that specific range.

Below is the syntax of the MATCH function in Excel.

  • lookup_value – The value for which you are looking for a match in the lookup_array.
  • lookup_array – The range of cells in which you are searching for the lookup_value.
  • [match_type] – (Optional) This specifies how excel should look for a matching value. It can take three values -1, 0 , or 1.

Understanding Match Type Argument in MATCH Function

There is one additional thing you need to know about the MATCH function, and it’s about how it goes through the data and finds the cell position.

The third argument of the MATCH function can be 0, 1 or -1.

Below is an explanation of how these arguments work:

  • 0 – this will look for an exact match of the value. If an exact match is found, the MATCH function will return the cell position. Else, it will return an error.
  • 1 – this finds the largest value that is less than or equal to the lookup value. For this to work, your data range needs to be sorted in ascending order.
  • -1 – this finds the smallest value that is greater than or equal to the lookup value. For this to work, your data range needs to be sorted in descending order.

Below is a video that explains how to use the MATCH function (along with the match type argument)

To summarize and put it in simple words:

  • INDEX needs the cell position (row and column number) and gives the cell value.
  • MATCH finds the position by using a lookup value.

Let’s Combine Them to Create a Powerhouse (INDEX + MATCH)

Now that you have a basic understanding of how INDEX and MATCH functions work individually, let’s combine these two and learn about all the wonderful things it can do.

To understand this better, I have a few examples that use the INDEX MATCH combination.

I will start with a simple example and then show you some advanced use cases as well.

Example 1: A simple Lookup Using INDEX MATCH Combo

Let’s do a simple lookup with INDEX/MATCH.

Below is a table where I have the marks for ten students.

From this table, I want to find the marks for Jim.

Below is the formula that can easily do this:

Now, if you’re thinking this can easily be done using a VLOOKUP function, you’re right! This is not the best use of INDEX MATCH awesomeness. Despite the fact that I am a fan of INDEX MATCH, it is a little more difficult than VLOOKUP. If fetching data from a column on the right is all you want to do, I recommend you use VLOOKUP.

The reason I have shown this example, which can also easily be done with VLOOKUP is to show you how INDEX MATCH works in a simple setting.

Now let me show a benefit of INDEX MATCH.

Suppose you have the same data, but instead of having it in columns, you have it in rows (as shown below).

You know what, you can still use INDEX MATCH combo to get Jim’s marks.

Below is the formula that will give you the result:

Note that you need to change the range and switch the row/column parts to make this formula work for horizontal data as well.

This can’t be done with VLOOKUP, but you can still do this easily with HLOOKUP.

Example 2: Lookup to the Left

It’s more common than you think.

A lot of times, you may be required to fetch the data from a column which is to the left of the column that has the lookup value.

Something as shown below:

To find out Michael’s sales, you will have to do a lookup on the left.

If you’re thinking VLOOKUP, let me stop your right there.

VLOOKUP is not made to look for and fetch the values on the left.

Can you still do it using VLOOKUP?

But that can turn into a long and ugly formula.

So if you want to do a lookup and fetch data from the columns on the left, you are better off using INDEX MATCH combo.

Below is the formula that will get Michael’s sales number:

Example 3: Two Way Lookup

So far, we have seen the examples where we wanted to fetch the data from the column adjacent to the column that has the lookup value.

But in real life, the data often spans through multiple columns.

INDEX MATCH can easily handle a two-way lookup.

Below is a dataset of the student’s marks in three different subjects.

If you want to quickly fetch the marks of a student in all three subjects, you can do that with INDEX MATCH.

The below formula will give you the marks for Jim for all the three subjects (copy and paste in one cell and drag to fill other cells or copy and paste on other cells).

Let me quickly also explain this formula.

INDEX formula uses B2:D11 as the range.

The first MATCH uses the name (Jim in cell F3) and fetches the position of it in the names column (A2:A11). This becomes the row number from which the data needs to be fetched.

The second MATCH formula uses the subject name (in cell G2) to get the position of that specific subject name in B1:D1. For example, Math is 1, Physics is 2 and Chemistry is 3.

Since these MATCH positions are fed into the INDEX function, it returns the score based on the student name and subject name.

This formula is dynamic, which means that if you change the student name or the subject names, it would still work and fetch the correct data.

Example 4: Lookup Value From Multiple Column/Criteria

Suppose you have a dataset as shown below and you want to fetch the marks for ‘Mark Long’.

Since the data is in two columns, I can’t a lookup for Mark and get the data.

If I do it that way, I am going to get the marks data for Mark Frost and not Mark Long (because the MATCH function will give me the result for the MARK it meets).

One way of doing this is to create a helper column and combine the names. Once you have the helper column, you can use VLOOKUP and get the marks data.

If you’re interested in learning how to do this, read this tutorial on using VLOOKUP with multiple criteria.

But with INDEX/MATCH combo, you don’t need a helper column. You can create a formula that handles multiple criteria in the formula itself.

The below formula will give the result.

Let me quickly explain what this formula does.

The MATCH part of the formula combines the lookup value (Mark and Long) as well as the entire lookup array. When $A$2:A11&”|”&$B$2:$B$11 is used as the lookup array, it actually checks the lookup value against the combined string of first and last name (separated by the pipe symbol).

This ensures that you get the right result without using any helper columns.

Example 5: Get Values from Entire Row/Column

In the examples above, we have used the INDEX function to get value from a specific cell. You provide the row and column number, and it returns the value in that specific cell.

But you can do more.

You can also use the INDEX function to get the values from an entire row or column.

And how can this be useful you ask!

Suppose you want to know the total score of Jim in all the three subjects.

You can use the INDEX function to first get all the marks of Jim and then use the SUM function to get a total.

Let’s see how to do this.

Below I have the scores of all the students in three subjects.

The below formula will give me the total score of Jim in all the three subjects.

Let me explain how this formula works.

The trick here is to use 0 as the column number.

When you use 0 as the column number in the INDEX function, it will return all the row values. Similarly, if you use 0 as the row number, it will return all the values in the column.

So the below part of the formula returns an array of values –

If you just enter this above formula in a cell in Excel and hit enter, you will see a #VALUE! error. This is because it’s not returning a single value, but an array of value.

But don’t worry, the array of values are still there. You can check this by selecting the formula and press the F9 key. It will show you the result of the formula which in this case is an array of three value –

Now, if you wrap this INDEX formula in the SUM function, it will give you the sum of all the marks scored by Jim.

You can also use the same to get the highest, lowest and average marks of Jim.

Just like we have done this for a student, you can also do this for a subject. For example, if you want the average score in a subject, you can keep the row number as 0 in the INDEX formula and it will give you all the column values of that subject.

Example 6: Find the Student’s Grade (Approximate Match Technique)

So far, we have used the MATCH formula to get the exact match of the lookup value.

But you can also use it to do an approximate match.

Now, what the hell is Approximate Match?

When you’re looking for stuff such as names or ids, you’re looking for an exact match. But sometimes, you need to know the range in which your lookup values lie. This is usually the case with numbers.

For example, as a class teacher, you may want to know what’s the grade of each student in a subject, and the grade is decided based on the score.

Below is an example, where I want the grade for all the students and the grading is decided based on the table on the right.

So if a student gets less than 33, the grade is F and if he/she gets less than 50 but more than 33, it’s E, and so on.

Below is the formula that will do this.

Let me explain how this formula works.

In the MATCH function, we have used 1 as the [match_type] argument. This argument will return the largest value that is less than or equal to the lookup value.

This means that the MATCH formula goes through the marks range, and as soon as it finds a marks range that is equal to or less than the lookup marks value, it will stop there and return its position.

So if the lookup mark value is 20, the MATCH function would return 1 and if it’s 85, it would return 5.

And the INDEX function uses this position value to get the grade.

Note that the above can also be done using below VLOOKUP formula:

But MATCH function can go a step further when it comes to approximate match.

You can also have a descending data and can use INDEX MATCH combo to find the result. For example, if I change the order of the grade table (as shown below), I can still find the grades of the students.

To do this, all I have to do is change the [match_type] argument to -1.

Below is the formula that I have used:

Example 7: Case Sensitive Lookups

So far all the lookups we have done have been case insensitive.

This means that whether the lookup value was Jim or JIM or jim, it didn’t matter. You’ll get the same result.

But what if you want the lookup to be case sensitive.

This is usually the case when you have large data sets and a possibility of repetition or distinct names/ids (with the only difference being the case)

For example, suppose I have the following data set of students where there are two students with the name Jim (the only difference being that one is entered as Jim and another one as jim).

Note that there are two students with the same name – Jim (cell A2 and A5).

Since a normal lookup wouldn’t work, you need to do a case sensitive lookup.

Below is the formula that will give you the right result. Since this is an array formula, you need to use Control + Shift + Enter.

Let me explain how this formula works.

The EXACT function checks for an exact match of the lookup value (which is ‘jim’ in this case). It goes through all the names and returns FALSE if it isn’t a match and TRUE if it’s a match.

So the output of the EXACT function in this example is –

Note that there is only one TRUE, which is when the EXACT function found a perfect match.

The MATCH function then finds the position of TRUE in the array returned by the EXACT function, which is 4 in this example.

Once we have the position, the INDEX function uses it to find the marks.

Example 8: Find the Closest Match

Let’s get a little advanced now.

Suppose you have a dataset where you want to find the person who has the work experience closest to the required experience (mentioned in cell D2).

While lookup formulas are not made to do this, you can combine it with other functions (such as MIN and ABS) to get this done.

Below is the formula that will find the person with the experience closest to the required one and return the name of the person. Note that the experience needs to be closest (which can be either less or more).

Since this is an array formula, you need to use Control + Shift + Enter.

The trick in this formula is to change the lookup value and lookup array to find the minimum experience difference in required and actual values.

Before I explain the formula, let’s understand how you would do it manually.

You will go through each cell in column B and find the difference in the experience between what is required and the one that a person has. Once you have all the differences, you will find the one which is minimum and fetch the name of that person.

This is exactly what we are doing with this formula.

The lookup value in the MATCH formula is MIN(ABS(D2-B2:B15)).

This part gives you the minimum difference between the given experience (which is 2.5 years) and all the other experiences. In this example, it returns 0.3

Note that I have used ABS to make sure I am looking for the closest (which can be more or less than the given experience).

Now, this minimum value becomes our lookup value.

The lookup array in the MATCH function is ABS(D2-$B$2:$B$15).

This gives us an array of numbers from which 2.5 (the required experience) has been subtracted.

MATCH function finds the position of 0.3 in this array, which is also the position of the person’s name who has the closest experience.

This position number is then used by the INDEX function to return the name of the person.

Example 9: Use INDEX MATCH with Wildcard Characters

If you want to look up a value when there is a partial match, then you need to use wildcard characters.

For example, below is a dataset of company name and their market capitalizations and you want to want to get the market cap. data for the three companies on the right.

Since these are not exact matches, you can’t do a regular lookup in this case.

But you can still get the right data by using an asterisk (*), which is a wildcard character.

Below is the formula that will give you the data by matching the company names from the main column and fetching the market cap figure for it.

Let me explain how this formula works.

Since there is no exact match of lookup values, I have used D2&”*” as the lookup value in the MATCH function.

An asterisk is a wildcard character that represents any number of characters. This means that Apple* in the formula would mean any text string that starts with the word Apple and can have any number of characters after it.

So when Apple* is used as the lookup value and the MATCH formula looks for it in column A, it returns the position of ‘Apple Inc.’, as it starts with the word Apple.

You can also use wildcard characters to find text strings where the lookup value is in between. For example, if you use *Apple* as the lookup value, it will find any string that has the word apple anywhere in it.

Note: This technique works well when you only have one instance of matching. But if you have multiple instances of matching (for example Apple Inc and Apple Corporation, then the MATCH function would return the position of the first matching instance only.

Example 10: Three Way Lookup

This is an advanced use of INDEX MATCH, but I will still cover it to show you the power of this combination.

Remember I said that INDEX function has two syntaxes:

So far in all our examples, we have only used the first one.

But for a three-way lookup, you need to use the second syntax.

Let me first explain what a three-way look means.

In a two-way lookup, we use the INDEX MATCH formula to get the marks when we have the student’s name and the subject name. For example, fetching the marks of Jim in Math is a two-way lookup.

A three-way look would add another dimension to it. For example, suppose you have a dataset as shown below and you want to know the score of Jim in Math in Mid-term exam, then this would be three-way lookup.

Below is the formula that will give the result.

The above formula checked for three things – the name of the student, the subject, and the exam. After it finds the right value, it returns it in the cell.

Let me explain how this formula works by breaking down the formula into parts.

  • array – ($B$3:$D$7,$B$11:$D$15,$B$19:$D$23): Instead of using a single array, in this case, I have used three arrays within parenthesis.
  • row_num – MATCH($F$5,$A$3:$A$7,0): MATCH function is used to find the position of the student’s name in cell $F$5 in the list of student’s name.
  • col_num – MATCH(G$4,$B$2:$D$2,0): MATCH function is used to find the position of the subject name in cell $B$2 in the list of subject’s name.
  • [area_num] – IF(G$3=”Unit Test”,1,IF(G$3=”Mid Term”,2,3)): The area number value tells the INDEX function which of the three arrays to use to fetch the value. If the exam is Unit Term, the IF function would return 1 and the INDEX function would use the first array to fetch the value. If the exam is Mid-term, the IF formula would return 2, else it will return 3.

This is an advanced example of using INDEX MATCH, and you’re unlikely to find a situation when you have to use this. But it’s still good to know what Excel formulas can do.

Why is INDEX/MATCH Better than VLOOKUP?

Yes, it is – in most cases.

I will present my case in a while.

But before I do that, let me say this – VLOOKUP is an extremely useful function and I love it. It can do a lot of things in Excel and I use it every now and then myself. Having said that, it doesn’t mean that there can’t be anything better, and INDEX/MATCH (with more flexibility and functionalities) is better.

So if you want to do some basic lookup, you’re better off using VLOOKUP.

INDEX/MATCH is VLOOKUP on steroids. And once you learn INDEX/MATCH, you might always prefer using it (especially because of the flexibility it has).

Without stretching it too far, let me quickly give you the reasons why INDEX/MATCH is better than VLOOKUP.

INDEX/MATCH can look to the Left (as well as to the right) of the lookup value

I covered it in one of the example above.

If you have a value which is on the left of the lookup value, you can’t do that with VLOOKUP

At least not with just VLOOKUP.

Yes, you can combine VLOOKUP with other formulas and get it done, but it gets complicated and messy.

INDEX/MATCH, on the other hand, is made to lookup everywhere (be it left, right, up, or down)

INDEX/MATCH can work with vertical and horizontal ranges

Again, with full respect to VLOOKUP, it’s not made to do this.

After all, the V in VLOOKUP stands for vertical.

VLOOKUP can only go through data that is vertical, while INDEX/MATCH can go through data vertically as well horizontally.

Of course, there is the HLOOKUP function to take care of horizontal lookup, but it isn’t VLOOKUP then.. right?

I like the fact that INDEX MATCH combo is flexible enough to work with both vertical and horizontal data.

VLOOKUP cannot work with descending data

When it comes to the approximate match, VLOOKUP and INDEX/MATCH are at the same level.

But INDEX MATCH takes the point as it can also handle data that is in descending order.

I show this in one of the examples in this tutorial where we have to find the grade of students based on the grading table. If the table is sorted in descending order, VLOOKUP would not work (but INDEX MATCH would).

INDEX/MATCH can be slightly faster

I will be truthful. I didn’t run this test myself.

I am relying on the wisdom an Excel master – Charley Kyd.

The difference in speed in VLOOKUP and INDEX/MATCH is hardly noticeable when you have small data sets. But if you have thousands of rows and many columns, this can be a deciding factor.

In his article, Charley Kyd states:

“At its worst, the INDEX-MATCH method is about as fast as VLOOKUP; at its best, it’s much faster.”

INDEX/MATCH is Independent of the Actual Column Position

If you have a dataset as shown below as you’re fetching the score of Jim in Physics, you can do that using VLOOKUP.

And to do that, you can specify the column number as 3 in VLOOKUP.

But what if I delete the Math column.

In that case, the VLOOKUP formula will break.

Why? – Because it was hardcoded to use the third column, and when I delete a column in between, the third column becomes the second column.

Using INDEX/MATCH, in this case, is better as you can make the column number dynamic by using MATCH. So instead of a column number, it checks for the subject name and uses that to return the column number.

Surely you can do that by combining VLOOKUP with MATCH, but if you combining anyway, why not do it with INDEX which is a lot more flexible.

When using INDEX/MATCH, you can safely insert/delete columns in your dataset.

Despite all these factors, there is a reason VLOOKUP is so popular.

And it’s a big reason.

VLOOKUP is easier to use

VLOOKUP only takes a maximum of four arguments. If you can wrap your head around these four, you’re good to go.

And since most of the basic lookup cases are handled by VLOOKUP as well, it has quickly become the most popular Excel function.

I call it the King of Excel functions.

INDEX/MATCH, on the other hand, is a little more difficult to use. You may get a hang if it when you start using it, but for a beginner, VLOOKUP is far more easy to explain and learn.

And this is not a zero-sum game.

So, if you’re new to the lookup world and don’t know how to use VLOOKUP, better learn that.

I have a detailed guide on using VLOOKUP in Excel (with lots of examples)

My intent in this article is not to pitch two awesome functions against each other. I wanted to show you the power of INDEX MATCH combo and all the great things it can do.

Hope you found this article useful.

Let me know your thoughts in the comments section, and in case you find any mistake in this tutorial, please let me know.

You May Also Like the Following Excel Tutorials:

Источник

You don’t need to inform the hiring manager reading your resume about where you’ve worked and what you’ve studied — you want to excite him or her by demonstrating to them how your previous job experience and education have given you the specific skills needed to excel in the position you’re applying for.

JOBS

Some of the major qualities you will need to excel in this position include communication, IT, and organizational skills.

JOBS

SELF STARTER & TEAM PLAYER… Eager to learn and master the tasks and tools needed to excel in each position.

JOBS

But like his function in the defensive phase, Khedira’s contribution is hard to grasp because he excels in position recognition and tactical intelligence:

SPORTS

With my experience providing comprehensive nursing care to patients suffering from a variety of mental disorders and psychological conditions, my background has prepared me to excel in this position.

JOBS

Starting with the summary section, it’s apparent that this candidate understands what it takes to excel in this position.

JOBS

Those with a knack for creative writing and a natural love of video games are sure to excel in this position.

GAMING

Especially Iwobi, he has good close control, stature and other skills that would make him excel in that position.

SPORTS

Branding statements should be tailored toward a particular job and show how you have the right stuff to excel in that position.

JOBS

Participants will have opportunities to gain knowledge, skills and experiences that will help them excel in positions of special education leadership.

EDUCATION

My skills and knowledge are part of the qualifications you seek, and I am more than confident I would excel in this position.

JOBS

He has d pace, trickery & pin-point crosses to excel in that position.

SPORTS

With your skills, experience and personality, you will excel in this position.

JOBS

Responsible for receiving and distributing money, people who excel in this position have a good grasp of basic math, the English language, clerical skills and customer service.

JOBS

You need to know your value as an employee and be able to show potential employers that you have the required passion, education, and experience to excel in the position you are applying for.

JOBS

Once you’ve got a fix on the institution, the department, and the open position, ask yourself what abilities or special qualities a candidate needs to excel in that position.

SCIENCE

This is where you need to make it clear that you have what it takes to excel in that position.

JOBS

Your OnTarget resume needs to provide an overview of your strengths and key talents to show that you have what it takes to excel in that position.

JOBS

That objective is to excel in the position you are going to be associated.

JOBS

Are there specific experiences you want to highlight to show you can excel in this position?

JOBS

If you feel that you have the skills and attributes to excel in this position, then I would like to hear from you today!

JOBS

If you’re an experienced candidate, your skills summary section probably does not include all of your key skills — only those that show you’ll excel in the position you’re applying to.

JOBS

[mention the strong points and abilities of the individual that will help him to excel in the position of a field service technician]

JOBS

Just make sure that you stay focused enough on the job you were hired for that you succeed and excel in that position before looking for the next one.

JOBS

I excelled in this position and quickly found myself performing more than my job requirements.

JOBS

While it can be hard to show hiring managers that you have the skills, knowledge or drive to excel in a position, by following the advice above, you have a better chance of presenting yourself in the clearest light possible.

JOBS

Recognized for polished communication, presentation, negotiation, and problem-solving skills, I have excelled in positions where forward looking market analysis, and proven client relationship management skills have been key to the successful growth of sales revenues and customer bases.

JOBS

Renee’s strengths as a communicator and a business seeker result in top-notch new business sales and have helped her excel in each position she has held in her staffing career: staffing consultant, professional direct hire recruiter, branch manager, sales manager, and account manager.

JOBS

Giving credence to those accomplishments in your resume that most effectively demonstrate your ability to excel in the position you are applying for is a great way set you aside as someone who is able to fulfill needs.

JOBS

While the interviewer wants to know why you are attracted to the job, he’ll be even more interested in hearing about why your experience has prepared you to excel in the position.

JOBS

You will face a series of often intensive test from numerical reasoning to personality, which will challenge your technical, mental and emotional ability to excel in the position and the company at large.

JOBS

This includes 22 % who believe Cuomo is excelling in the position and 42 % who think his performance is a good one.

POLITICS

You’ll learn about the many opportunities within the firm while building the skills necessary to excel in those positions, and receive expert advice from the firm’s senior leaders, the campus recruitment team and program alumni.

JOBS

It should speak to the unique needs of the employer, be full of industry expertise, and show that you know how to excel in the position.

JOBS

When another reporter asked Quinn about the former First Lady being a good fit as mayor, the speaker responded «I think Hillary Clinton would excel in any position she ever takes.»

POLITICS

With my extensive IT training, exceptional problem-solving skills, relevant projects and professional experience, I am confident of excelling in the position of IT Analyst at Popular Industries.

JOBS

Excel has a lot of functions – about 450+ of them.

And many of these are simply awesome. The amount of work you can get done with a few formulas still surprises me (even after having used Excel for 10+ years).

And among all these amazing functions, the INDEX MATCH functions combo stands out.

I am a huge fan of INDEX MATCH combo and I have made it pretty clear many times.

I even wrote an article about Index Match Vs VLOOKUP which sparked a little bit of debate (you can check the comments section for some firework).

And today, I am writing this article solely focussed on Index Match to show you some simple and advanced scenarios where you can use this powerful formula combo and get the work done.

Note: There are other lookup formulas in Excel – such as VLOOKUP and HLOOKUP and these are great. Many people find VLOOKUP to be easier to use (and that’s true as well). I believe INDEX MATCH is a better option in many cases. But since people find it difficult, it gets used less. So I am trying to simplify it using this tutorial.

Now before I show you how the combination of INDEX MATCH is changing the world of analysts and data scientists, let me first introduce you to the individual parts – INDEX and MATCH functions.

INDEX Function: Finds the Value-Based on Coordinates

The easiest way to understand how Index function works is by thinking of it as a GPS satellite.

As soon as you tell the satellite the latitude and longitude coordinates, it will know exactly where to go and find that location.

So despite having a mind-boggling number of lat-long combinations, the satellite would know exactly where to look.

I quickly did a search for my work location and this is what I got.

Index Match in Excel is like Lat Long in a Map

Anyway, enough of geography.

Just like a satellite needs latitude and longitude coordinates, the INDEX function in Excel would need the row and column number to know what cell you’re referring to.

And that’s Excel INDEX function in a nut-shell.

So let me define it in simple words for you.

The INDEX function will use the row number and column number to find a cell in the given range and return the value in it.

Finding a cell in Excel using row and column number

All by itself, INDEX is a very simple function, with no utility. After all, in most cases, you are not likely to know the row and column numbers.

But…

The fact that you can use it with other functions (hint: MATCH) that can find the row number and the column number makes INDEX an extremely powerful Excel function.

Below is the syntax of the INDEX function:

=INDEX (array, row_num, [col_num])
=INDEX (array, row_num, [col_num], [area_num])
  • array – a range of cells or an array constant.
  • row_num – the row number from which the value is to be fetched.
  • [col_num] – the column number from which the value is to be fetched. Although this is an optional argument, but if row_num is not provided, it needs to be given.
  • [area_num] – (Optional) If array argument is made up of multiple ranges, this number would be used to select the reference from all the ranges.

INDEX function has 2 syntaxes (just FYI).

The first one is used in most cases. The second one is used in advanced cases only (such as doing a three-way lookup) which we will cover in one of the examples later in this tutorial.

But if you’re new to this function, just remember the first syntax.

Below is a video that explains how to use the INDEX function

MATCH Function: Finds the Position baed on a Lookup Value

Going back to my previous example of longitude and latitude, MATCH is the function that can find these positions (in the Excel spreadsheet world).

In simple language, the Excel MATCH function can find the position of a cell in a range.

And on what basis would it find a cell’s position?

Based on the lookup value.

For example, if you have a list as shown below and you want to find the position of the name ‘Mark’ in it, then you can use the MATCH function.

Match Function in Excel - Finding Mark Name

The function returns 3, as that’s the position of the cell with the name Mark in it.

MATCH function starts looking from top to bottom for the lookup value (which is ‘Mark’) in the specified range (which is A1:A9 in this example). As soon as it finds the name, it returns the position in that specific range.

Below is the syntax of the MATCH function in Excel.

=MATCH(lookup_value, lookup_array, [match_type])
  • lookup_value – The value for which you are looking for a match in the lookup_array.
  • lookup_array – The range of cells in which you are searching for the lookup_value.
  • [match_type] – (Optional) This specifies how excel should look for a matching value. It can take three values -1, 0 , or 1.

Understanding Match Type Argument in MATCH Function

There is one additional thing you need to know about the MATCH function, and it’s about how it goes through the data and finds the cell position.

The third argument of the MATCH function can be 0, 1 or -1.

Below is an explanation of how these arguments work:

  • 0 – this will look for an exact match of the value. If an exact match is found, the MATCH function will return the cell position. Else, it will return an error.
  • 1 – this finds the largest value that is less than or equal to the lookup value. For this to work, your data range needs to be sorted in ascending order.
  • -1 – this finds the smallest value that is greater than or equal to the lookup value. For this to work, your data range needs to be sorted in descending order.

Below is a video that explains how to use the MATCH function (along with the match type argument)

To summarize and put it in simple words:

  • INDEX needs the cell position (row and column number) and gives the cell value.
  • MATCH finds the position by using a lookup value.

Let’s Combine Them to Create a Powerhouse (INDEX + MATCH)

Now that you have a basic understanding of how INDEX and MATCH functions work individually, let’s combine these two and learn about all the wonderful things it can do.

To understand this better, I have a few examples that use the INDEX MATCH combination.

I will start with a simple example and then show you some advanced use cases as well.

Click here to download the example file

Example 1: A simple Lookup Using INDEX MATCH Combo

Let’s do a simple lookup with INDEX/MATCH.

Below is a table where I have the marks for ten students.

Example 1 - Students Marks

From this table, I want to find the marks for Jim.

Below is the formula that can easily do this:

=INDEX($A$2:$B$11,MATCH("Jim",$A$2:$A$11,0),2)

Jims Marks using Index Match

Now, if you’re thinking this can easily be done using a VLOOKUP function, you’re right! This is not the best use of INDEX MATCH awesomeness. Despite the fact that I am a fan of INDEX MATCH, it is a little more difficult than VLOOKUP. If fetching data from a column on the right is all you want to do, I recommend you use VLOOKUP.

The reason I have shown this example, which can also easily be done with VLOOKUP is to show you how INDEX MATCH works in a simple setting.

Now let me show a benefit of INDEX MATCH.

Suppose you have the same data, but instead of having it in columns, you have it in rows (as shown below).

Horizontal Data Set for Lookup

You know what, you can still use INDEX MATCH combo to get Jim’s marks.

Below is the formula that will give you the result:

=INDEX($B$1:$K$2,2,MATCH(“Jim”,$B$1:$K$1,0))

Using Index Match with Horizontal Data

Note that you need to change the range and switch the row/column parts to make this formula work for horizontal data as well.

This can’t be done with VLOOKUP, but you can still do this easily with HLOOKUP.

INDEX MATCH  combination can easily handle horizontal as well as vertical data.

Click here to download the example file

Example 2: Lookup to the Left

It’s more common than you think.

A lot of times, you may be required to fetch the data from a column which is to the left of the column that has the lookup value.

Something as shown below:

Left Lookup Data

To find out Michael’s sales, you will have to do a lookup on the left.

If you’re thinking VLOOKUP, let me stop your right there.

VLOOKUP is not made to look for and fetch the values on the left.

Can you still do it using VLOOKUP?

Yes, you can!

But that can turn into a long and ugly formula.

So if you want to do a lookup and fetch data from the columns on the left, you are better off using INDEX MATCH combo.

Below is the formula that will get Michael’s sales number:

=INDEX($A$2:$C$11,MATCH("Michael",C2:C11,0),2)

Left Look-up Formula - INDEX MATCH Combo

Another point here for INDEX MATCH. VLOOKUP can fetch the data only from the columns that are to the right of the column that has the lookup value.

Example 3: Two Way Lookup

So far, we have seen the examples where we wanted to fetch the data from the column adjacent to the column that has the lookup value.

But in real life, the data often spans through multiple columns.

INDEX MATCH can easily handle a two-way lookup.

Below is a dataset of the student’s marks in three different subjects.

Three Way Lookup - Data set

If you want to quickly fetch the marks of a student in all three subjects, you can do that with INDEX MATCH.

The below formula will give you the marks for Jim for all the three subjects (copy and paste in one cell and drag to fill other cells or copy and paste on other cells).

=INDEX($B$2:$D$11,MATCH($F$3,$A$2:$A$11,0),MATCH(G$2,$B$1:$D$1,0))

Three Way Lookup result - using INDEX MATCH Combo

Let me quickly also explain this formula.

INDEX formula uses B2:D11 as the range.

The first MATCH uses the name (Jim in cell F3) and fetches the position of it in the names column (A2:A11). This becomes the row number from which the data needs to be fetched.

The second MATCH formula uses the subject name (in cell G2) to get the position of that specific subject name in B1:D1. For example, Math is 1, Physics is 2 and Chemistry is 3.

Since these MATCH positions are fed into the INDEX function, it returns the score based on the student name and subject name.

This formula is dynamic, which means that if you change the student name or the subject names, it would still work and fetch the correct data.

One great thing about using INDEX/MATCH is that even if you interchange the names of the subjects, it will continue to give you the correct result.

Example 4: Lookup Value From Multiple Column/Criteria

Suppose you have a dataset as shown below and you want to fetch the marks for ‘Mark Long’.

Multiple Criteria Lookup Dataset

Since the data is in two columns, I can’t a lookup for Mark and get the data.

If I do it that way, I am going to get the marks data for Mark Frost and not Mark Long (because the MATCH function will give me the result for the MARK it meets).

One way of doing this is to create a helper column and combine the names. Once you have the helper column, you can use VLOOKUP and get the marks data.

If you’re interested in learning how to do this, read this tutorial on using VLOOKUP with multiple criteria.

But with INDEX/MATCH combo, you don’t need a helper column. You can create a formula that handles multiple criteria in the formula itself.

The below formula will give the result.

=INDEX($C$2:$C$11,MATCH($E$3&"|"&$F$3,$A$2:A11&"|"&$B$2:$B$11,0))

Multiple Criteria Lookup result - INDEX &MATCH

Let me quickly explain what this formula does.

The MATCH part of the formula combines the lookup value (Mark and Long) as well as the entire lookup array. When $A$2:A11&”|”&$B$2:$B$11 is used as the lookup array, it actually checks the lookup value against the combined string of first and last name (separated by the pipe symbol).

This ensures that you get the right result without using any helper columns.

You can do this kind of lookup (where there are multiple columns/criteria) with VLOOKUP as well, but you need to use a helper column. INDEX MATCH combo makes it slightly easy to do this without any helper columns.

Example 5: Get Values from Entire Row/Column

In the examples above, we have used the INDEX function to get value from a specific cell. You provide the row and column number, and it returns the value in that specific cell.

But you can do more.

You can also use the INDEX function to get the values from an entire row or column.

And how can this be useful you ask!

Suppose you want to know the total score of Jim in all the three subjects.

You can use the INDEX function to first get all the marks of Jim and then use the SUM function to get a total.

Let’s see how to do this.

Below I have the scores of all the students in three subjects.

The below formula will give me the total score of Jim in all the three subjects.

=SUM(INDEX($B$2:$D$11,MATCH($F$4,$A$2:$A$11,0),0))

Get Entire Row with Index Function

Let me explain how this formula works.

The trick here is to use 0 as the column number.

When you use 0 as the column number in the INDEX function, it will return all the row values. Similarly, if you use 0 as the row number, it will return all the values in the column.

So the below part of the formula returns an array of values – {97, 70, 73}

INDEX($B$2:$D$11,MATCH($F$4,$A$2:$A$11,0),0)

If you just enter this above formula in a cell in Excel and hit enter, you will see a #VALUE! error. This is because it’s not returning a single value, but an array of value.

But don’t worry, the array of values are still there. You can check this by selecting the formula and press the F9 key. It will show you the result of the formula which in this case is an array of three value – {97, 70, 73}

Now, if you wrap this INDEX formula in the SUM function, it will give you the sum of all the marks scored by Jim.

You can also use the same to get the highest, lowest and average marks of Jim.

Just like we have done this for a student, you can also do this for a subject. For example, if you want the average score in a subject, you can keep the row number as 0 in the INDEX formula and it will give you all the column values of that subject.

Click here to download the example file

Example 6: Find the Student’s Grade (Approximate Match Technique)

So far, we have used the MATCH formula to get the exact match of the lookup value.

But you can also use it to do an approximate match.

Now, what the hell is Approximate Match?

Let me explain.

When you’re looking for stuff such as names or ids, you’re looking for an exact match. But sometimes, you need to know the range in which your lookup values lie. This is usually the case with numbers.

For example, as a class teacher, you may want to know what’s the grade of each student in a subject, and the grade is decided based on the score.

Below is an example, where I want the grade for all the students and the grading is decided based on the table on the right.

Grade for Students - Dataset

So if a student gets less than 33, the grade is F and if he/she gets less than 50 but more than 33, it’s E, and so on.

Below is the formula that will do this.

=INDEX($F$3:$F$8,MATCH(B2,$E$3:$E$8,1),1)

Grade for Students results - Approximate Match

Let me explain how this formula works.

In the MATCH function, we have used 1 as the [match_type] argument. This argument will return the largest value that is less than or equal to the lookup value.

This means that the MATCH formula goes through the marks range, and as soon as it finds a marks range that is equal to or less than the lookup marks value, it will stop there and return its position.

So if the lookup mark value is 20, the MATCH function would return 1 and if it’s 85, it would return 5.

And the INDEX function uses this position value to get the grade.

IMPORTANT: For this to work, your data needs to be sorted in ascending order. If it’s not, you can get wrong results.

Note that the above can also be done using below VLOOKUP formula:

=VLOOKUP(B2,$E$3:$F$8,2,TRUE)

But MATCH function can go a step further when it comes to approximate match.

You can also have a descending data and can use INDEX MATCH combo to find the result. For example, if I change the order of the grade table (as shown below), I can still find the grades of the students.

Approximate Match to find students grades

To do this, all I have to do is change the [match_type] argument to -1.

Below is the formula that I have used:

=INDEX($F$3:$F$8,MATCH(B2,$E$3:$E$8,-1),1)

VLOOKUP can also do an approximate match but only when data is sorted in ascending order(but it doesn’t work if the data is sorted in descending order).

Example 7: Case Sensitive Lookups

So far all the lookups we have done have been case insensitive.

This means that whether the lookup value was Jim or JIM or jim, it didn’t matter. You’ll get the same result.

But what if you want the lookup to be case sensitive.

This is usually the case when you have large data sets and a possibility of repetition or distinct names/ids (with the only difference being the case)

For example, suppose I have the following data set of students where there are two students with the name Jim (the only difference being that one is entered as Jim and another one as jim).

Data for case sensitive lookup

Note that there are two students with the same name – Jim (cell A2 and A5).

Since a normal lookup wouldn’t work, you need to do a case sensitive lookup.

Below is the formula that will give you the right result. Since this is an array formula, you need to use Control + Shift + Enter.

=INDEX($B$2:$B$11,MATCH(TRUE,EXACT(D3,A2:A11),0),1)

Doing a case sensitive lookup with Index Match

Let me explain how this formula works.

The EXACT function checks for an exact match of the lookup value (which is ‘jim’ in this case). It goes through all the names and returns FALSE if it isn’t a match and TRUE if it’s a match.

So the output of the EXACT function in this example is – {FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}

Note that there is only one TRUE, which is when the EXACT function found a perfect match.

The MATCH function then finds the position of TRUE in the array returned by the EXACT function, which is 4 in this example.

Once we have the position, the INDEX function uses it to find the marks.

Example 8: Find the Closest Match

Let’s get a little advanced now.

Suppose you have a dataset where you want to find the person who has the work experience closest to the required experience (mentioned in cell D2).

Find Closest match - dataset

While lookup formulas are not made to do this, you can combine it with other functions (such as MIN and ABS) to get this done.

Below is the formula that will find the person with the experience closest to the required one and return the name of the person. Note that the experience needs to be closest (which can be either less or more).

=INDEX($A$2:$A$15,MATCH(MIN(ABS(D2-B2:B15)),ABS(D2-$B$2:$B$15),0))

Since this is an array formula, you need to use Control + Shift + Enter.

Find Closest match using INDEX MATCH Combo

The trick in this formula is to change the lookup value and lookup array to find the minimum experience difference in required and actual values.

Before I explain the formula, let’s understand how you would do it manually.

You will go through each cell in column B and find the difference in the experience between what is required and the one that a person has. Once you have all the differences, you will find the one which is minimum and fetch the name of that person.

This is exactly what we are doing with this formula.

Let me explain.

The lookup value in the MATCH formula is MIN(ABS(D2-B2:B15)).

This part gives you the minimum difference between the given experience (which is 2.5 years) and all the other experiences. In this example, it returns 0.3

Note that I have used ABS to make sure I am looking for the closest (which can be more or less than the given experience).

Now, this minimum value becomes our lookup value.

The lookup array in the MATCH function is ABS(D2-$B$2:$B$15).

This gives us an array of numbers from which 2.5 (the required experience) has been subtracted.

So now we have a lookup value (0.3) and a lookup array ({6.8;0.8;19.5;21.8;14.5;11.2;0.3;9.2;2;9.8;14.8;0.4;23.8;2.9})

MATCH function finds the position of 0.3 in this array, which is also the position of the person’s name who has the closest experience.

This position number is then used by the INDEX function to return the name of the person.

Related Read: Find the Closest Match in Excel (examples using lookup formulas)

Click here to download the example file

Example 9: Use INDEX MATCH with Wildcard Characters

If you want to look up a value when there is a partial match, then you need to use wildcard characters.

For example, below is a dataset of company name and their market capitalizations and you want to want to get the market cap. data for the three companies on the right.

Market Cap data of companies

Since these are not exact matches, you can’t do a regular lookup in this case.

But you can still get the right data by using an asterisk (*), which is a wildcard character.

Below is the formula that will give you the data by matching the company names from the main column and fetching the market cap figure for it.

=INDEX($B$2:$B$10,MATCH(D2&”*”,$A$2:$A$10,0),1)

Using INDEX MATCH with Wildcard Characters

Let me explain how this formula works.

Since there is no exact match of lookup values, I have used D2&”*” as the lookup value in the MATCH function.

An asterisk is a wildcard character that represents any number of characters. This means that Apple* in the formula would mean any text string that starts with the word Apple and can have any number of characters after it.

So when Apple* is used as the lookup value and the MATCH formula looks for it in column A, it returns the position of ‘Apple Inc.’, as it starts with the word Apple.

You can also use wildcard characters to find text strings where the lookup value is in between. For example, if you use *Apple* as the lookup value, it will find any string that has the word apple anywhere in it.

Note: This technique works well when you only have one instance of matching. But if you have multiple instances of matching (for example Apple Inc and Apple Corporation, then the MATCH function would return the position of the first matching instance only.

Example 10: Three Way Lookup

This is an advanced use of INDEX MATCH, but I will still cover it to show you the power of this combination.

Remember I said that INDEX function has two syntaxes:

=INDEX (array, row_num, [col_num]) 
=INDEX (array, row_num, [col_num], [area_num])

So far in all our examples, we have only used the first one.

But for a three-way lookup, you need to use the second syntax.

Let me first explain what a three-way look means.

In a two-way lookup, we use the INDEX MATCH formula to get the marks when we have the student’s name and the subject name. For example, fetching the marks of Jim in Math is a two-way lookup.

A three-way look would add another dimension to it. For example, suppose you have a dataset as shown below and you want to know the score of Jim in Math in Mid-term exam, then this would be three-way lookup.

Three Way Lookup Dataset

Below is the formula that will give the result.

=INDEX(($B$3:$D$7,$B$11:$D$15,$B$19:$D$23),MATCH($F$5,$A$3:$A$7,0),MATCH(G$4,$B$2:$D$2,0),(IF(G$3="Unit Test",1,IF(G$3="Mid Term",2,3))))

Three Way Lookup - Result using INDEX MATCH

The above formula checked for three things – the name of the student, the subject, and the exam. After it finds the right value, it returns it in the cell.

Let me explain how this formula works by breaking down the formula into parts.

  • array – ($B$3:$D$7,$B$11:$D$15,$B$19:$D$23): Instead of using a single array, in this case, I have used three arrays within parenthesis.
  • row_num – MATCH($F$5,$A$3:$A$7,0): MATCH function is used to find the position of the student’s name in cell $F$5 in the list of student’s name.
  • col_num – MATCH(G$4,$B$2:$D$2,0): MATCH function is used to find the position of the subject name in cell $B$2 in the list of subject’s name.
  • [area_num] – IF(G$3=”Unit Test”,1,IF(G$3=”Mid Term”,2,3)): The area number value tells the INDEX function which of the three arrays to use to fetch the value. If the exam is Unit Term, the IF function would return 1 and the INDEX function would use the first array to fetch the value. If the exam is Mid-term, the IF formula would return 2, else it will return 3.

This is an advanced example of using INDEX MATCH, and you’re unlikely to find a situation when you have to use this. But it’s still good to know what Excel formulas can do.

Click here to download the example file

Why is INDEX/MATCH Better than VLOOKUP?

OR Is it?

Yes, it is – in most cases.

I will present my case in a while.

But before I do that, let me say this – VLOOKUP is an extremely useful function and I love it. It can do a lot of things in Excel and I use it every now and then myself. Having said that, it doesn’t mean that there can’t be anything better, and INDEX/MATCH (with more flexibility and functionalities) is better.

So if you want to do some basic lookup, you’re better off using VLOOKUP.

INDEX/MATCH is VLOOKUP on steroids. And once you learn INDEX/MATCH, you might always prefer using it (especially because of the flexibility it has).

Without stretching it too far, let me quickly give you the reasons why INDEX/MATCH is better than VLOOKUP.

INDEX/MATCH can look to the Left (as well as to the right) of the lookup value

I covered it in one of the example above.

If you have a value which is on the left of the lookup value, you can’t do that with VLOOKUP

At least not with just VLOOKUP.

Yes, you can combine VLOOKUP with other formulas and get it done, but it gets complicated and messy.

INDEX/MATCH, on the other hand, is made to lookup everywhere (be it left, right, up, or down)

INDEX/MATCH can work with vertical and horizontal ranges

Again, with full respect to VLOOKUP, it’s not made to do this.

After all, the V in VLOOKUP stands for vertical.

VLOOKUP can only go through data that is vertical, while INDEX/MATCH can go through data vertically as well horizontally.

Of course, there is the HLOOKUP function to take care of horizontal lookup, but it isn’t VLOOKUP then.. right?

I like the fact that INDEX MATCH combo is flexible enough to work with both vertical and horizontal data.

VLOOKUP cannot work with descending data

When it comes to the approximate match, VLOOKUP and INDEX/MATCH are at the same level.

But INDEX MATCH takes the point as it can also handle data that is in descending order.

I show this in one of the examples in this tutorial where we have to find the grade of students based on the grading table. If the table is sorted in descending order, VLOOKUP would not work (but INDEX MATCH would).

INDEX/MATCH can be slightly faster

I will be truthful. I didn’t run this test myself.

I am relying on the wisdom an Excel master – Charley Kyd.

The difference in speed in VLOOKUP and INDEX/MATCH is hardly noticeable when you have small data sets. But if you have thousands of rows and many columns, this can be a deciding factor.

In his article, Charley Kyd states:

“At its worst, the INDEX-MATCH method is about as fast as VLOOKUP; at its best, it’s much faster.”

INDEX/MATCH is Independent of the Actual Column Position

If you have a dataset as shown below as you’re fetching the score of Jim in Physics, you can do that using VLOOKUP.

Three Way Lookup - Data set

And to do that, you can specify the column number as 3 in VLOOKUP.

All is fine.

But what if I delete the Math column.

In that case, the VLOOKUP formula will break.

Why? – Because it was hardcoded to use the third column, and when I delete a column in between, the third column becomes the second column.

Using INDEX/MATCH, in this case, is better as you can make the column number dynamic by using MATCH. So instead of a column number, it checks for the subject name and uses that to return the column number.

Surely you can do that by combining VLOOKUP with MATCH, but if you combining anyway, why not do it with INDEX which is a lot more flexible.

When using INDEX/MATCH, you can safely insert/delete columns in your dataset.

Despite all these factors, there is a reason VLOOKUP is so popular.

And it’s a big reason.

VLOOKUP is easier to use

VLOOKUP only takes a maximum of four arguments. If you can wrap your head around these four, you’re good to go.

And since most of the basic lookup cases are handled by VLOOKUP as well, it has quickly become the most popular Excel function.

I call it the King of Excel functions.

INDEX/MATCH, on the other hand, is a little more difficult to use. You may get a hang if it when you start using it, but for a beginner, VLOOKUP is far more easy to explain and learn.

And this is not a zero-sum game.

So, if you’re new to the lookup world and don’t know how to use VLOOKUP, better learn that.

I have a detailed guide on using VLOOKUP in Excel (with lots of examples)

My intent in this article is not to pitch two awesome functions against each other. I wanted to show you the power of INDEX MATCH combo and all the great things it can do.

Hope you found this article useful.

Let me know your thoughts in the comments section, and in case you find any mistake in this tutorial, please let me know.

You May Also Like the Following Excel Tutorials:

  • Excel Functions
  • 100+ Excel Interview Questions
  • Find the Last Occurrnece of a Lookup Value in a List
  • Lookup the Second, the Third, or the Nth Value in Excel
  • Use IFERROR with VLOOKUP to Get Rid of #N/A Errors

You are here

Home » Learn Microsoft Excel » Use the MATCH function in Excel to find the position of a value in a list

Use the MATCH function in Excel to find the position of a value in a list

.

The MATCH() function allows you to find the relative position of a value in a list in Excel. For example, in a list of weekdays starting with Monday first, MATCH() would return a value of 3 for Wednesday. This lesson explains how to use the MATCH() function in Microsoft Excel, explains where you might use it, and provides a real world example of the MATCH() function in action.

MATCH() Function Syntax

The MATCH() function has the following syntax:

=MATCH(lookup_value,lookup_array,match_type)

  • lookup_value is the value you want to find in the list. It is required for the function to work.
  • lookup_array is the range of cells that contain the list. It is required for the function to work.
  • match_type is an optional value that defines the type of match you are looking for. It can have three possible values, -1, 0 and 1. If you leave it out Excel assumes a value of 1.

The MATCH function finds the position of your lookup_value in the range of cells you’re looking in (the lookup_array). It’s important to note that if your list doesn’t include the lookup_value, the MATCH function will return a #NA error.

Crucial — understanding the match_type parameter

Understanding the match_type parameter is the key to using the MATCH function effectively.

Although match_type is optional, I recommend you always set it to the correct value when using the MATCH function. Otherwise your MATCH functions won’t always return the results you expect.

  • A match_type value of 1 should be used when your list is sorted in ascending order (smallest to largest).

    • If your list contains your lookup_value more than once, MATCH will return the position of the last instance of that value.
    • If your list is not sorted you will sometimes get the right answer, but sometimes you’ll get a #N/A error.
    • If your list doesn’t contain your lookup_value, MATCH will return the position of the next largest value.
    • If you don’t supply a match_type, Excel will automatically use 1 as the match_type.
  • A match_type value of 0 means your list doesn’t need to be sorted.

    • MATCH will look for an exact match for your lookup_value in the list
    • MATCH will return the position of the first occurrence of the lookup_value it finds, even if there are duplicates in the list
    • Important — MATCH will return a #N/A error if the lookup_value is not in the list.
  • A match_type value of -1 should be used when your list is sorted in descending order (largest to smallest).

    • If your list is not sorted you will sometimes get the right answer, but sometimes you’ll get a #N/A error.
    • If your list contains your lookup_value more than once, MATCH will return the position of the last instance in the list of that value.
    • If your list doesn’t contain your lookup_value, MATCH will return the position of the next smallest value.

Using the MATCH function in Excel — find a match in a list without duplicates

This example looks at how to use the MATCH function if your list doesn’t contain any duplicates.

  • The data for this example is a list of people’s names. The list is not sorted alphabetically.
  • We want to find where a particular person appears in the list. In this case, we know each person only appears once.
  • In this situation, you should set match_type to 0. If you don’t, Excel will set match_type to 1, and your formula is likely to return the wrong result.

  • You enter the MATCH function into your spreadsheet as follows:
    Using the MATCH function in Excel to find the position of a name in an unsorted list
  • In the example above, B12 contains the MATCH function, which returns a value of 5 since Ramit is 4th in the list.

    • Note that you will get a #N/A result if you enter a name into B11 that doesn’t exist in the list.
  • B13 shows us the MATCH function as it was entered:

    • The value to find a match for is in B11. We could also have entered Ramit into the MATCH function direcly as the lookup value rather than referencing B11.

    • The range of cells to look up is A3:A9, i.e. the cells containing our list of names.
    • We have set the match_type parameter to 0 because each name appears only once.

The MATCH function in action — finding a match in a list with duplicates

MATCH gets more complicated when you have lists that contain duplicate values since MATCH can only return one value. In other words, even if you have the value you are looking for appears 3 times, MATCH can only give you the position of one of those values.

Using MATCH in an unsorted list that contains duplicate values

  • If your list contains duplicates but is not sorted, the most reliable way to use MATCH is to set match_type to 0.

    • This will return the position of the first instance of match_type on your list.
    • Also, it will only return a result if there is an exact match. Setting match_type to 1 or -1 when your list is not sorted will return unpredictable and sometimes incorrect results.
  • In this example, we have list of numbers that is not sorted and contains duplicate values. We want to find the position of a certain number on that list
    Using MATCH in Excel to find the position of a value in an unsorted list that contains duplicates
  • In the example above, we are looking for the position of 52 in the list. As you can see, 52 is repeated three times in the list.
  • The position returned by the MATCH function in this example is 6 because this is the first instance of 52 that MATCH encountered (when starting from the list and working down). The other two values are ignored by the MATCH function.
  • This is a very important fact to remember. MATCH can only find one instance of a value in a list. It will not let you look specifically for the second or third instances of a value in a list.

Using MATCH in an list sorted in ascending order with duplicate values


  • If your list is sorted in ascending order, you should set match_type to 1.

    • You can also leave the match_type value out altogether, since Excel will assume a value for 1 if match_type is not present.
  • The following example uses the same set of numbers as the previous example:
    Using MATCH in Excel to find a value in a list sorted in ascending order that contains duplicate values
  • In this example, note that the list is sorted and that 52 occupies positions 5, 6 and 7 in the list.
  • The MATCH function, with match_type set to 1, has returned 7. This is because the last instance of 52 on the list is in position 7.
  • Once again, remember that MATCH can only return one value from the list.

    • If you want MATCH to return the position of the first instance of 52, you could set match_type to 0.
    • There is no reliable way to get MATCH to return the position of the second instance of 52 in the list.

Using MATCH in an list sorted in descending order with duplicate values

  • If your list is sorted in descending order, you should set match_type to -1.
  • The following example uses the same set of numbers as the previous two examples:
    Using MATCH in Excel to find the position of a value in a list sorted in descending order that contains duplicate values
  • In this example, note that the list is sorted and that 52 occupies positions 5, 6 and 7 in the list.
  • The MATCH function, with match_type set to -1, has returned 7. As with the previous example, this is because the last instance of 52 on the list is in position 7.
  • Once again, remember that MATCH can only return one value from the list.

    • If you want MATCH to return the position of the first instance of 52, you could set match_type to 0.
    • There is no reliable way to get MATCH to return the position of the second instance of 52 in the list.

Summary of the MATCH function

MATCH performs a very specific and somewhat limited function in Excel. If you are planning to use MATCH in your spreadsheets, make sure you understand the job that match_type does in determining how the MATCH function will decide what result to return. It is also a good idea to include match_type when you use the MATCH function even if you don’t need to. That avoids mistakes, and makes troubleshooting easier.

.

Want to learn more? Try these lessons:

.

.

Our Comment Policy.

We welcome your comments and questions about this lesson. We don’t welcome spam. Our readers get a lot of value out of the comments and answers on our lessons and spam hurts that experience. Our spam filter is pretty good at stopping bots from posting spam, and our admins are quick to delete spam that does get through. We know that bots don’t read messages like this, but there are people out there who manually post spam. I repeat — we delete all spam, and if we see repeated posts from a given IP address, we’ll block the IP address. So don’t waste your time, or ours. One other point to note — if you post a link in your comment, it will automatically be deleted.

Add a comment to this lesson

.

Comments on this lesson

How to find second, third, etc

You wrote:
«There is no reliable way to get MATCH to return the position of the second instance of 52 in the list.»

[I am discussing only the situation with match_type = 1. That is, the list is assumed to be sorted in ascending order.]

This may be true only if you are limiting yourself to worksheet functions. If you drop into Visual Basic, it is a snap.

You find a match, not necessarily the first one, but any one.
Then you run up the values until you find the first non-match. Now move down one at a time and count matches until you get to the particular match you want, or run out of them.

.

Need to get value in a raw, when entering another value

Hi,
I have my Employee details in sheet2, i.e. name, E-code, designation.

When I enter one name in sheet1, I need the particular Employee’s E-code to be displayed in the next cell of that particular raw.

Thanks to someone who would help in this.

Amar Lopez

.

above question

You enter the name at Sheet1, the name should be same and unique of the Sheet2 emp information.
Go to next cell of name at Sheet 2 then enter the following formula
B2=VLOOKUP(A2,Sheet2!A2:B7,2,0)
Here A2 = given Name
B2= system will give emp code
A2:B7 at Sheet 2 is the list of emp information.

.

Error in explanation of lookup_value=1

If lookup_value = 1 in a list sorted in ascending order, then MATCH returns the position of the value that is smaller than or equal to the lookup_value.
So, your text is wrong, as it states that is will return the next larger value in such case.

.

dsfsf

.

.

.

.

.

In Excel you may need to lookup just part of the text in a cell. For example, if you have a cell that contains a transaction description and within that description there is a product name.

EXCEL LOOKUP PART OF CELL

You want to lookup the price of that product from a table. Let’s look at three possibilities:

    1. When the product name is just randomly placed within the lookup text: “Sold WHEEL to John’s Motors Ltd”
    2. As 1. above but there are always defined characters before and after the product name: “Sold –WHEEL– to John’s Motors Ltd”
    3. The product name is always in the same part of the string: “AA2 WHL Sold – JM1″

Obviously the third possibility in the list is the easiest to solve in Excel so lets begin there.

Lookup Part of Text in Cell: Consistent Start and End Points

The VLOOKUP (or HLOOKUP) function has the following arguments: LOOKUP VALUE, TABLE, COLUMNS INDEX NUMBER, EXACT/NON-EXACT MATCH. As the LOOKUP VALUE is only part of the cell, we need to consider how we can extract the text we want from the cell.

Check FIG(a1) for the LOOKUP VALUE sources and TABLE ARRAY.

Fig 1a: Lookup Part of Cell | Consistent start and end points

Fig(a1)

Find the LOOKUP VALUE Part of the Cell

Since in this case the start point in each source cell is consistently character 5 and the length of the LOOKUP VALUE will always be 3 characters (such as “WHL” in cell D8), we can use the MID function to extract the LOOKUP VALUE. The MID function just needs the TEXT, START CHARACTER NUMBER and NUMBER OF CHARACTERS.

In our example lets start by inputting the MID function in cell F8. You can see the result in FIG(a2).

LOOKUP PART OF CELL EX1 FIGA2

Fig(a2)

The result of this we now just need to use in our VLOOKUP formula. The LOOKUP TABLE being in range $H$8:$I$10, COLUMN INDEX NUMBER is 2 (the second column in the table) and in this case we only want to return exact matches so the final argument will be ‘FALSE’.

Finalize the Formula to Lookup Part of the Cell

Putting that formula together in our cell F8 is:

=VLOOKUP(MID($D8, 5, 3), $H$8:$I$10, 2, FALSE)

Copying down that formula next to our transactions completes the lookup of prices FIG(a3).

LOOKUP PART OF CELL EX1 FIGA3

Fig(a3)

Moving on to our next scenario.

Lookup Part of Text: Using a Consistent Character as Separator

In this case we will use the separator ‘-‘ to define the start and end of the LOOKUP VALUES in the source cells. This method works as long as the separator character is only used to identify the Product Name. If appears elsewhere in the text then you can proceed to scenario 3 which can handle the LOOKUP VALUE anywhere in the cell.

LOOKUP PART OF CELL EX1 FIGB1

Fig(b1)

Use the Dashes to Separate the LOOKUP VALUE

You can see in FIG(b1) that if we find the dashes ‘-‘ we will be able to extract the needed text using the MID function. To do this we will need to know the starting character for “Wheel” and the number of characters in “Wheel”. We will use the FIND function to identify the placement of our separators and do these calculations.

LOOKUP PART OF CELL EX1 FIGB2

Fig(b2)

FIND first separator

In FIG(b2) you can see the make up of the FIND function to locate the start of “Wheel”. The FIND function has the following arguments: FIND TEXT, WITHIN TEXT and an optional CHARACTER START NUMBER. This third optional argument is useful when you are looking for the second or subsequent separator. We will use it later but for now we can ignore it.

So putting our FIND function in cell F17. [FIG(b2)] you can see it has returned the placement of the of the first dash.

=FIND(“-“,   $D17)

FIND second separator

Now, lets find the second separator so we can find the end of our LOOKUP VALUE. We are going to do this by doing another FIND formula. This time though we will need to use the START NUMBER to make sure we skip past the separator we’ve already discovered.

Fig(b3)

In FIG(b3) you can see the first two arguments of the second FIND are exactly the same. But to skip over the first separator we need to get the number for this from cell F17 (+1 to jump past it).

=FIND(“-“,   $D17F17+1)

Use MID Function to Get the LOOKUP VALUE

LOOKUP PART OF CELL EX1 FIGB4

Fig(b4)

Now we have those results we can put together a MID function (as used in the first scenario).

FIG(b4). The first argument of the MID function is just our transaction description. Second is the start point which is our first FIND function. Next we need the number of characters to extract. We can calculate this as our second FIND result less the first. You can see we have extracted the LOOKUP VALUE.

=MID($D17,   F17+1,   G17-1-F17)

Before going on to the last step lets combine our functions. You can do this by editing the cell with the first FIND and copying everything after the “=”. Leave this cell then edit our MID function in cell …. highlight the reference to cell …. and paste. Repeat this for the second FIND function. Great, that’s our MID function complete.

You should end up with this:

=MID($D17FIND(“-“,   $D17)+1FIND(“-“, $D17,FIND(“-“,$D17)+1)   -1    -FIND(“-“,   $D17))

LOOKUP PART OF CELL EX1 FIGB5

Fig(b5)

VLOOKUP part of text

Finally we can do our VLOOKUP using this MID function as the LOOKUP VALUE. In FIG(b6) you can see we’ve referenced this cell, input our table, selected the second column and indicated we want exact match (FALSE).

LOOKUP PART OF CELL EX1 FIGB6

Fig(b6)

=VLOOKUP(F17,   $J$17:$K$19,   2,   FALSE)

We will just replace the reference to cell F17 with the formula in that cell. Copy that down and we’re done FIG(b7).

=VLOOKUP(MID($D17,  FIND(“-“,   $D17)+1,  FIND(“-“, $D17,FIND(“-“,$D17)+1)   -1    -FIND(“-“,   $D17)),   $J$17:$K$19,   2,   FALSE)

LOOKUP PART OF CELL EX1 FIGB7

Fig(b7)

There are a few steps there but hopefully the logic makes sense. Now lets move on to the final scenario where you can lookup pretty much any of the possible Product Names wherever they appear in our source text.

Lookup Part of Text: Randomly Placed Text in Cell

In order to lookup part of text in a cell that is randomly placed; we are going to need something other than the VLOOKUP function. Instead we are going to create a fairly complicated ARRAY FORMULA that uses INDEX, MATCH, ISERROR and FIND. If any of these functions are unfamiliar, don’t worry. Just follow it through. Once you’ve built the array formula hopefully you can understand the logic in those functions.

The Logic In This Solution

Lets consider the logic of this approach to look up part of the cell. We are going to use what I’ll call a reverse lookup. I.e. we’re going to try each of the items in column H (the first column of our lookup table) to see if the text in those cells is anywhere in our source cell (the descriptions in column D). Once we’ve found one that matches, we’ll look down the corresponding data in column I and get the result.

Ok, lets begin by seeing if we can find an item in column H that is in our lookup source cells.

ARRAY Formulas

An ARRAY formula allows us to use an array of values (compared with a standard equivalent formula where we’d just be able to use a single value).

You may be aware that the FIND function returns an error if it can’t locate the searched text. E.g. =FIND(“C”,  “ABD”) returns an error.

So as part of an ARRAY formula, =FIND({“A”,”B”,”C”,”D”},     “SAMPLE TEXT”) would return {2,ERROR,ERROR,ERROR}.

Applying that to our data would result be: =FIND({“Chrome Wheel”,”Bearings”,”Wheel”,”Tyre”},     “Sold Wheel to John’s Motors Ltd”) and return {ERROR,ERROR,6,ERROR}

Hopefully you can see this may be useful. If we can identify where the first non-error occurs we can find the position in the table for our result.

MATCH Function In ARRAY FORMULA

To find the non-error we can use MATCH function to look through the results of the FIND array.

Before we do that lets use the ISERROR function to convert {ERROR,ERROR,6,ERROR} to {TRUE,TRUE,FALSE,TRUE}.

Now instead of numbers we have FALSE to look for.

The FALSE results are the nuggets we’re looking for.

To find the placement of the FALSE we can use the MATCH function. So “=MATCH(FALSE,  {TRUE,TRUE,FALSE,TRUE},   0)” in an ARRAY formula is going to return 3.

Lets try inputting the ARRAY FORMULA so far to make sure it is working as expected. See FIG(c1) for the formula.

{=MATCH(FALSE, ISERROR(SEARCH($H$31:$H$34, $D31)), 0)}

To enter an ARRAY formula, press SHIFT+CTRL+ENTER (rather than just ENTER). This tells Excel you want an array formula. You don’t type the leading and ending {}. Hitting SHIFT+CTRL+ENTER will put these in. Make sure you check these are shown once you’ve done the SHIFT+CTRL+ENTER.

You can see this is returning 3 which is the correct row in our table for “Wheel”.

LOOKUP PART OF CELL EX1 FIGC1

Fig(c1)

Complete the Lookup with INDEX Function

We’re almost done with the tutorial. All we need to do now is use this result in an INDEX function.

If you’re not familiar with the INDEX function the arguments are: ARRAY, ROW NUMBER, and optional COLUMN number. We can complete this with one column so the final argument won’t be needed for this example.

So our INDEX function looks at the lookup table and identify the cell you want from the table by identifying which row to select from it.

Putting this altogether you can see the result in FIG(c2). So we’re looking down our table in column I by the number of rows identified by the MATCH function.

{=INDEX($I$31:$I$34, MATCH(FALSE, ISERROR(SEARCH($H$31:$H$34, $D31)), 0))}

LOOKUP PART OF CELL EX1 FIGC2

Fig(c2)

We can copy this down and we have results for all our lookups.

What To Watch Out For

  1. The FIND function is case sensitive. To remove this sensitivity, you can either keep the data in column H in upper case and amend the formula to: INDEX($I$31:$I$34, MATCH(FALSE, ISERROR(FIND($H$31:$H$34, UPPER($D31))), 0)). Fig(c3). Or you can replace FIND with SEARCH. The SEARCH function is not case sensitive.
  2. You need to think about the order of your data in the lookup table. As Excel is going to run down the data in column H it will find the first match. A cell with the words “….CHROME WHEEL…” could match to both “WHEEL” and “CHROME WHEEL”. So in this case you’d want to ensure “CHROME WHEEL” was above “WHEEL” in your table. You

    LOOKUP PART OF CELL EX1 FIGC3

    Fig(c3)

    may resolve this problem by sorting your list by length of “Product Name”.

Hopefully you find this functionality useful. If you have any questions or comments please post them below.

You can also learn how to create a hyperlink to VLOOKUP or SUMIF results.

And if you’re looking to include wildcards in the ‘lookup what’ then check out these wildcard examples.

In this article, we will learn how you can remove a number of characters from a string from a starting position.
003
The excel REPLACE function gives a us the functionality to replace number of characters from a string to with another string.

Generic Formula to Remove Text From a Position

=REPLACE(string, start_position, num_of_chars, “”)

String: this is the original string from which you want to remove characters.

Start_position: starting position in string.

Num_of_chars: number of characters you want to remove.

“” (blank): Replaces given characters from nothing. Ultimately removing the text.
Example 1: Remove Text From a String with Fixed Length.
Here I have list of fully qualified names of .xlsm files. I just want have only file’s name in list and remove every thing else.
004
Since “C:UsersManish SinghDesktopExcel Tip” is the parent folder of each file and it is of 40 characters, we will write this formula to remove this common text from string.

This excel formula removes 40 characters starting from first character.
005
Example 2: Remove Text From a String with Variable Length
In above example the length of text was fixed for removing. If the length of text which need to be removed is not fixed than take help of excel SEARCH function. This function returns the position of found text.

The above example was from one computer. If the data was compiled from different users then the structure of file path would be different. Only common thing will be the main directory, which is set to be name common. In my example it is Excel Tip.
006
So now to remove non required text from string write this formula.

007
How did it work?

Let’s start from inside.SEARCH(«Excel Tip»,A2)+9: the search part will return the position of “Excel Tip” in A2. which is 23. Now since it is the position of starting «Excel Tip» in the string. We need the ending position of the text. Since “excel tip/” is a total of 10 characters we added 9 to get an accurate number. Hence we get 32.

Now the formula translates to REPLACE(A2,1,32,»»). This formula removed non required text from string.

Same happens with all the strings.

So yeah guys, this is how you can remove text from the string in excel. Note that this tutorial was about removing text not extracting text in excel. However, both are very similar tasks in excel. You can find extraction tutorials below.

Related Articles:
Extract Text From A String In Excel Using Excel’s LEFT And RIGHT Function
Excel Formula to Extract Unique Values From a List
Remove first characters from text

Popular Articles

50 Excel Shortcut to Increase Your Productivity: Get faster at your task. These 50 shortcuts will make you work even faster on Excel.

How to use the VLOOKUP Function in Excel: This is one of the most used and popular functions of excel that is used to lookup value from different ranges and sheets.

How to use the COUNTIF function in Excel: Count values with conditions using this amazing function. You don’t need to filter your data to count specific values. Countif function is essential to prepare your dashboard.

How to use the SUMIF Function in Excel: This is another dashboard essential function. This helps you sum up values on specific conditions.

How to get the relative row numbers for a range or table. How to find the relative row position of one Cell value in a specified Range or table. This post will guide you how to get the relative position of all rows in a range or table in excel. And how to get the relative row position of an item in a table or excel range.

  • Get the Relative Row Position of all Rows in Range
  • Get the Relative Row number of an item in a Range

Table of Contents

  • Get the Relative Row Position of all Rows in Range
  • Get the Relative Row number of an item in a Range
    • Related Formulas
    • Related Functions

Get the Relative Row Position of all Rows in Range

Supposing that you have a table that contain the data as the below picture.

Get the Relative Row Position of all Rows in Range

If you want to know the relative row position for all rows in an Excel Range (B3:D6), you can use a excel Array formula as follows:

=ROW(B3:D6)- ROW(B3) + 1

Get the Relative Row Position of all Rows in Range2

Note: when you enter into the above formula in Cell F3, you must be press “CTRL”+”Shift”+ Enter to indicate that formula is an array formula.

Let’s see how the above array formula works:

=ROW (B3:D6)

Get the Relative Row Position of all Rows in Range3

The first ROW function will return an array that contain 4 row numbers (absolute position) as elements.

=ROW (B3)

Get the Relative Row Position of all Rows in Range4

The above Row function in array formula will also return an array contain only one element (row number of Cell B3)

=ROW(B3:D6)- ROW(B3)

Get the Relative Row Position of all Rows in Range5

The result returned by the second ROW function is subtracted by the result returned by the First ROW function and it will return another Array as below:

{0;1;2;3}

Then the each value in the above array add 1 to get the relative row position of all rows in Range B3:D6, like the below array:

{1;2;3;4}

You can also use another excel array formula to get the same result as follows:

=ROW(B3:D6)-ROW(INDEX(B3:D6,1,1))+1

The INDEX function will return the reference of the first row in the range B3:D6, in other words, returns the reference of Cell B3.

Get the Relative Row Position of all Rows in Range6

Get the Relative Row number of an item in a Range

Suppose that you have a table of data such as the above picture. If you want to get the row position of the highest price in a range (B3:D6), you can use the MAX function within the MATCH function to get the relative row position of the highest price in a range or a table. Just using the following excel formula:

=MATCH(MAX(D3:D6),D3:D6,0)

The MAX function returns the highest price as $20 in range D3:D6.

Get the Relative Row number of an item in a Range1

Then the MATCH function will search for a value returned by the MAX function in range D3:D6, then it returns the relative position of $20.

Get the Relative Row Position of all Rows in Range7

You will see that the above formula returns 2, because the second row in the range of D3:D6 have the highest price.


  • Combine Text from Two or More Cells into One Cell
    If you want to combine text from multiple cells into one cell and you can use the Ampersand (&) symbol.If you are using the excel 2016, then you can use a new function TEXTJOIN function to combine text from multiple cells…
  • Split Text String to an Array
    If you want to convert a text string into an array that split each character in text as an element, you can use an excel formula to achieve this result. the below will guide you how to use a combination of the MID function, the ROW function, the INDIRECT function and the LEN function to split a string…

  • Excel INDEX function
    The Excel INDEX function returns a value from a table based on the index (row number and column number)The INDEX function is a build-in function in Microsoft Excel and it is categorized as a Lookup and Reference Function.The syntax of the INDEX function is as below:= INDEX (array, row_num,[column_num])…
  • Excel ROW function
    The Excel ROW function returns the row number of a cell reference.The ROW function is a build-in function in Microsoft Excel and it is categorized as a Lookup and Reference Function.The syntax of the ROW function is as below:= ROW ([reference])….
  • Excel MATCH  function
    The Excel MATCH function search a value in an array and returns the position of that item.The MATCH function is a build-in function in Microsoft Excel and it is categorized as a Lookup and Reference Function.The syntax of the MATCH function is as below:= MATCH  (lookup_value, lookup_array, [match_type])….

Понравилась статья? Поделить с друзьями:
  • Excel in sql server 2008
  • Excel in one column but not another
  • Excel in her studies
  • Excel in everything you do
  • Excel in english online