Yes, you can match the second or third instance of a value in Excel, but the standard VLOOKUP function cannot do this on its own. You must combine it with the MATCH function or use the FILTER function in newer Excel versions. This technique allows you to pull the second occurrence of a product name, the third email address in a list, or the second price from a dataset, even if the data is unsorted.
What You'll Need
- A spreadsheet application (Microsoft Excel, Google Sheets, or LibreOffice Calc).
- A dataset containing the value you want to match and the data you want to retrieve.
- Basic familiarity with spreadsheet formulas (specifically INDEX, MATCH, and FILTER).
Step-by-Step
Below are the two most common methods to achieve this. The first method works in all versions of Excel, while the second is specific to modern Excel (Office 365 or Excel 2021+).
Method 1: Using INDEX and MATCH (Works in all versions)
This method uses the MATCH function to find the position of the second instance and the INDEX function to return the value at that position. The logic is: Find the position of the item, add 1 to it to skip the first one, and return the value at the new position.
- Locate your data. Identify the column containing the values you want to match (often called the Lookup Column) and the column containing the result you want to retrieve (the Result Column). For example, if you have a list of sales in Column A and corresponding product names in Column B, you might want to find the second product name for a specific sales ID.
- Enter the formula in an empty cell. Click on the cell where you want the result to appear.
- Enter the INDEX function. Type
=INDEX(ReturnRange, RowNumber). ReplaceReturnRangewith the range of cells that contains the data you want to retrieve (e.g.,B:Bfor the product names). This is the range from which you will pull the value. - Enter the MATCH function. The MATCH function will calculate the row number. The syntax is
=MATCH(LookupValue, LookupRange, 0). ReplaceLookupValuewith the cell containing the value you are searching for (e.g.,A2). ReplaceLookupRangewith the range of cells that contains the values you are searching through (e.g.,A:A). The0at the end tells Excel to look for an exact match. - Combine the functions. Nest the MATCH function inside the INDEX function. The formula should now look like this:
=INDEX(B:B, MATCH(A2, A:A, 0) + 1). This formula translates to: Go to column B, find the row where column A equals A2, add 1 to that row number, and return the value from that new row number. - Adjust for the correct column. The
+1at the end of the formula tells Excel to skip the first instance and look for the second one. If you need to match the third instance, change the+1to+2. If you need the fourth, use+3, and so on. - Drag the formula down. Click the small square in the bottom-right corner of the cell with your formula and drag it down to apply it to the rest of your dataset.
Method 2: Using the FILTER Function (Office 365 / Excel 2021+)
This is the most concise method for modern Excel users. The FILTER function can be instructed to return only the second, third, or nth item from a range.
- Locate your data. Again, identify your Lookup Column and your Result Column.
- Enter the formula in an empty cell. Click on the cell where you want the result to appear.
- Enter the FILTER function. Type
=FILTER(ResultRange, LookupRange=LookupValue). ReplaceResultRangewith the column containing the data you want to retrieve (e.g.,B:B). ReplaceLookupRangewith the column containing the values you are searching through (e.g.,A:A). ReplaceLookupValuewith the cell containing the value you are searching for (e.g.,A2). This formula will return all instances of the value. - Add the SEQUENCE function. To get only the second instance, you need to tell Excel to return the 2nd item in the list. Type
=SEQUENCE(2)at the beginning of your formula. The2inside the parenthesis tells Excel to create a list of numbers starting at 1 and ending at 2. This will be used to index the results of the FILTER function. - Combine the functions. The final formula will look like this:
=FILTER(B:B, A:A=A2, SEQUENCE(2)). This formula translates to: Filter column B where column A equals A2, and then return the 1st and 2nd items from that filtered list. - Drag the formula down. Drag the formula down to apply it to the rest of your dataset.
Common Mistakes
- Incorrect Lookup Range. The most common error is using the wrong range for the MATCH function. The range you search in (e.g., Column A) must be exactly the same height as the range you return from (e.g., Column B). If your data has headers or is missing rows, the formula will return
#N/Aor an incorrect value. - Forgetting the exact match (0). In the MATCH function, the third argument is crucial. If you omit it or put a 1 or -1 in it, Excel will attempt to find the closest match to your value, which will almost always result in an incorrect answer. Always use
0for exact matching. - Not accounting for hidden rows. Both methods described above look at all rows in the specified range, regardless of whether they are hidden or filtered. If you are using Excel's filter feature to hide rows, the formula will still count them. This is rarely a problem, but it is important to understand.
- Complexity of array formulas. In older versions of Excel (pre-2019), the INDEX and MATCH method is the standard way to do this. However, some users attempt to use array formulas (like
INDEX($B$2:$B$100, SMALL(IF($A$2:$A$100=$E2, ROW($A$2:$A$100)-ROW($A$2)+1), 2))) which are much more complex and prone to errors. The simpler INDEX and MATCH method shown above is the most robust and easiest to maintain.
Tips
- Sort your data first. While not strictly necessary for these formulas to work, sorting your data alphabetically or numerically can make it much easier to spot errors and verify that your results are correct. It also helps in debugging if the formula is returning unexpected values.
- Use structured references (Tables). If your data is in an official Excel Table (Insert > Table), you can use table names in your formulas instead of column letters. For example, . This makes your formulas self-documenting and less prone to breaking if you insert or delete columns.
- Check for errors. If your formula returns
#N/A, it usually means that the value you are searching for does not exist in the lookup range, or that there are fewer instances of that value than the number you are trying to match (e.g., you are looking for the 5th instance, but there are only 3 total). - Combine with IFERROR. To make your spreadsheet look cleaner, wrap your formula in an IFERROR function. This will display a user-friendly message (like "Not Found") instead of an error code. The syntax is
=IFERROR(INDEX(B:B, MATCH(A2, A:A, 0) + 1), "Not Found").
Troubleshooting
If your formula is not working as expected, follow these steps to identify and fix the issue.
Formula returns #N/A
This is the most common error. First, verify that the LookupValue (the value you are searching for) actually exists in the LookupRange. Check for any extra spaces or hidden characters that might make the value look different (e.g., "Apple " vs. "Apple"). If the value does exist, check the +1 or +2 offset. If you are trying to match the second instance, but there is only one instance of the value in your data, the formula will return #N/A because it is trying to find a row that does not exist.
Formula returns a value from the wrong row
This usually indicates an error in the LookupRange or the ReturnRange. Ensure that both ranges are exactly the same size (same number of rows) and point to the correct columns. For example, if you are matching in Column A and returning from Column B, the ranges should be A:A and B:B. If you accidentally use A:A and A:A, you will get the second value from the same column you are searching in, which is rarely the intended result.
Formula returns #VALUE!
This error often occurs when the LookupRange or ReturnRange contains non-numeric data that cannot be interpreted as a number. For example, if you are using a numeric lookup value but your lookup range contains text, the MATCH function may fail. Ensure that your data types are consistent. Also, check for any accidental text formatting (like an apostrophe at the start of a number) in your cells.
Formula returns the first instance instead of the second
If you are using the INDEX and MATCH method, the most likely cause is that you forgot to add the +1 (or the appropriate offset) to the end of the formula. The MATCH function only finds the position of the first instance of the value. You must add the offset to skip that first instance and look for the next one. If you are using the FILTER method, ensure you are using SEQUENCE(2) to get the first two items, or SEQUENCE(3) to get the first three, and so on.
Frequently Asked Questions
Can I use VLOOKUP to find the second instance of a value?
No, the standard VLOOKUP function is designed to find the first (and only the first) instance of a value in a range. To find the second or third instance, you must use a combination of INDEX and MATCH or the FILTER function, as described in this guide.
Why does my formula return #REF!
The #REF! error indicates that your formula is referencing a cell that no longer exists. This can happen if you delete a column that was part of your ReturnRange or LookupRange. You can fix this by rebuilding the formula or by restoring the deleted column.
How do I match the 5th instance of a value?
Simply add the appropriate number to your formula. If you are using INDEX and MATCH, change the +1 to +4. If you are using FILTER, change the SEQUENCE(2) to SEQUENCE(5). The offset is always one less than the instance number you are trying to match (e.g., for the 5th instance, you add 4).
Does this work in Google Sheets?
Yes, both the INDEX and MATCH method and the FILTER function are fully supported in Google Sheets. The syntax and functionality are identical to Microsoft Excel.
What if there are duplicate values in the Result Column?
If your Result Column (the column you are returning data from) contains duplicates, this method will retrieve the duplicate values associated with the second instance of the lookup value. For example, if you are matching a Sales ID and there are two sales with that ID, this formula will return the value from the second sale. It does not remove duplicates from the result; it simply finds the value corresponding to the second matching row.