How to Vlookup with Multiple Matches in Excel (with Easy Steps)

Download Practice Workbook


Step 1 – Create Unique Name for Each Lookup Value

  • Insert a new column with the heading Helper Column left to the lookup column Book Type and enter the formula below in cell B5.
=C5&COUNTIF(C5:$C$25,C5)
Formula Breakdown

  • COUNTIF(C5:$C$25,C5) returns the total number of cells in the range C5:C25 (Book Type) that contain the value in cell C5 (Novel). See the COUNTIF function for details.
    • In simple words, how many novels there are. It is 7.
  • C5&COUNTIF(C5:$C$25,C5) concatenates the value in cell C5 (Novel) with it.
    • So it returns Novel7.

Dragging the Fill Handle tool, C5 increments one by one, like C5, C6, C7… but C25 remains constant. For each Book Type, the earlier ones get excluded and a new name is generated.

  • Press ENTER.

Vlookup with Multiple Matches in Excel

  • Place the cursor to the right-bottom corner of cell B5 to get the Fill Handle
  • Double-click on it.

Using Fill Handle tool

It copies the formula to the rest of the cells. You will find all the lookup values provided with a unique name, like Novel1, Novel2…, Poetry1, Poetry2…, etc.

Creating Unique Name for Each Lookup Value

Read More: VLOOKUP and Return All Matches in Excel (7 Ways)


Step 2 – Use VLOOKUP Function

  • Create a new column with Column Header as the lookup value.

Using VLOOKUP Function

  • Insert the following formula in cell G5:
=VLOOKUP(G$4&ROW($A$1:INDIRECT("A"&COUNTIF($C$5:$C$25,G$4))),$B$5:$E$25,3,FALSE)
Formula Breakdown

  • COUNTIF($C$5:$C$25,G$4) tells how many cells in the range C5:C25 (Book Type) contain the value in cell G4 (Novel).
    • In simple words, how many novels there are in total. It is 7.

We have used the absolute cell reference of the range C5:C25 ($C$5:$C$25) because we want it to remain unchanged if we copy the formula to any cell.

  • INDIRECT(“A”&COUNTIF($C$5:$C$25,G$4)) becomes INDIRECT(“A”&7) and returns the cell reference A7. See the INDIRECT function for details.
  • ROW($A$1:INDIRECT(“A”&COUNTIF($C$5:$C$25,G$4))) now becomes ROW(A1:A7).See the ROW function for details.
    • It returns an array from 1 to 7 like {1, 2, 3, 4, 5, 6, 7}.

We used $A$1 because we do not want it to change if we copy the formula to another cell.

  • G$4&ROW($A$1:INDIRECT(“A”&COUNTIF($C$5:$C$25,G$4))) now concatenates the value in cell G4 (Novel) with the array returned by the ROW function and returns another array.
    • So it returns {Novel1, Novel2, …, Novel7}.
  • VLOOKUP(G$4&ROW($A$1:INDIRECT(“A”&COUNTIF($C$5:$C$25,G$4))),$B$5:$E$25,3,FALSE) becomes VLOOKUP({Novel1, Novel2, …, Novel7},$B$5:$E$25,3,FALSE).

It searches for each value of the array {Novel1, Novel2, … Novel7} in the lookup column B.

Then it returns the corresponding name of the novel from the 3rd column (as the col_index_num is 3).

  • Press ENTER.

Using VLOOKUP Function to vlookup with multiple matches

Note: It’s an array formula. So don’t forget to press Ctrl + Shift + Enter unless you are in Excel 365.

And for the other Book Types,

  • Insert their names side by side as Column Headers and drag the Fill Handle.

using fill handle to vlookup with multiple matches


Similar Readings


Alternative Ways to Vlookup with Multiple Matches in Excel

Method 1 – Using FILTER Function

  • Insert the Book Type as the Column Header and enter the following formula in cell F5.
=FILTER($C$5:$C$25,$B$5:$B$25=F$4)
Formula Breakdown

Here,

  • $C$5:$C$25 (Book Name) is the lookup_array. We are looking for the names of the books. You use your one.
  • $B$5:$B$25 (Book Type) is the matching_array. We want to match the book types. You use your one accordingly.
  • F4 (Novel) is the matching_value. We want to match the novels. You use it accordingly.
  • Press ENTER.

Using FILTER Function

  • If you want the Book Names of all the Book Types,
    • Insert their names as the Column Headers side by side and the drag the Fill Handle tool.

Using FILTER Function to vlookup with multiple matches

Read More: 10 Best Practices with VLOOKUP in Excel


Method 2 – Applying Combination of INDEX, SMALL, and ROWS Functions (Compatible with Older Versions of Excel)

  • Insert the Book Type as the Column Header in cell F4 and enter the formula below in cell F5.
=IFERROR(INDEX($C$5:$C$25,(SMALL(IF($B$5:$B$25=F4,ROW(B5:B25)-ROWS(B1:B4),""),(ROW(B5:B25)-ROWS(B1:B4))))),"")

Formula Breakdown

  • ROW(B5:B25) returns an array of {5, 6, 7, …, 25}. And ROWS(B1:B4) returns 4. So ROW(B5:B25)-ROWS(B1:B4) returns an array of {1, 2, 3, …, 21}. See the ROW and ROWS function for details.
  • IF($B$5:$B$25=F4,ROW(B5:B25)-ROWS(B1:B4),””) returns the corresponding number from the array {1, 2, 3, …, 21} the value in cell F4 (Novel) matches the value in any cell of the range B5:B25 (Book Type). Otherwise returns a blank cell. See the IF function for details.

Part of IF function in the formula

  • SMALL(IF($B$5:$B$25=F4,ROW(B5:B25)-ROWS(B1:B4),””),(ROW(B5:B25)-ROWS(B1:B4))) becomes SMALL({1, …, 3, …, 6, …, 20, …},{1, 2, 3, 4, …., 21}) and returns the numbers first, then #NUM! errors in the blank cells. See the SMALL function for details.

  • INDEX($C$5:$C$25,(SMALL(IF($B$5:$B$25=F4,ROW(B5:B25)-ROWS(B1:B4),””),(ROW(B5:B25)-ROWS(B1:B4))))) becomes INDEX($C$5:$C$25,{1,3,6,11,…,#NUM!}) and returns the corresponding Book Names (Name of the Novels) and #NUM! errors. See the INDEX function for details.

INDEX function

  • We have wrapped the formula inside an IFERROR function to turn the errors into blank cells.
  • Press ENTER.

Using complex formula to vlookup with multiple matches

  • Insert the other Book Types as Column Headers and drag the Fill Handle.

Using Combination of INDEX, SMALL, and ROWS Functions

Read More: 7 Practical Examples of VLOOKUP Function in Excel


Method 3 – Vlookup with Multiple Matches and Return Results in a Row

  • Go to cell G5 and enter the formula below.
=IFERROR(INDEX($D$5:$D$19,SMALL(IF($F5=$B$5:$B$19,ROW($D$5:$D$19)-4,""),COLUMN()-6)),"")
  • Press ENTER.

Vlookup with Multiple Matches and Return Results in a Row

Drag the Fill Handle to right up to cell K5 to get the other Authors of Novel. Drag the Fill Handle tool to cell K7 to get the names of Authors for different types of book. See the image below for clarification.


How to Vlookup Numerous Matches with Several Criteria

  • Select cell H5 and enter the following formula.
=IFERROR(INDEX($C$5:$C$25,SMALL(IF(1=((--($F$5=$B$5:$B$25))*(--($G$5=$D$5:$D$25))),ROW($C$5:$C$25)-4,""),ROW()-4)),"")
  • Press ENTER.

How to Vlookup Numerous Matches with Several Criteria


How to Vlookup and Return Multiple Matches in One Cell

  • Go to cell G5 and enter the formula below.
=TEXTJOIN(", ",TRUE,IF($F$5=$B$5:$B$25,C5:C25,""))

The IF function gets the value from the range C5:C25 where the corresponding values in the range B5:B25 match the value in cell F5. The TEXTJOIN function combines the values of the array with a comma as the delimiter.

  • Press ENTER.

How to Vlookup and Return Multiple Matches in One Cell

Read More: INDEX MATCH vs VLOOKUP Function (9 Practical Examples)


Further Readings

<< Go Back to VLOOKUP Multiple Values | Excel VLOOKUP Function | Excel Functions | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Rifat Hassan
Rifat Hassan

Rifat Hassan, BSc, Electrical and Electronic Engineering, Bangladesh University of Engineering and Technology, has worked with the ExcelDemy project for almost 2 years. Within these 2 years, he has written over 250 articles. He has also conducted a few Boot Camp sessions on effective coding, especially Visual Basic for Applications (VBA). Currently, he is working as a Software Developer to develop and deploy additional add-ins to enhance the customers with a more sophisticated experience with Microsoft Office Suits,... Read Full Bio

2 Comments
  1. I have used this formula: =IFERROR(VLOOKUP(G$3&ROW($A$1:INDIRECT(“A”&COUNTIF($C$4:$C$1276;G$3)));$B$4:$F$1403;3;FALSE);””)
    and somehow it worked for one column, not for the rest? And if I have only 1 in my list it will fill with just that one. Instead of just show that one in 1 line?

    • Hi there,

      I’ve applied your formula after correcting the typos (you’ve used semicolons instead of commas) and it is working fine.
      =IFERROR(VLOOKUP(G$3&ROW($A$1:INDIRECT("A"&COUNTIF($C$4:$C$1276,G$3))),$B$4:$F$1403,3,FALSE),"")

      If you still face the problem, please explain it in detail so we can help you. Thanks for being with us.

      Regards,
      Md. Shamim Reza (ExcelDemy Team)

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo