## VLOOKUP multiple matches – trick

We all know that VLOOKUP can find first match and return the results. But what if you want to VLOOKUP multiple matches? Use this simple trick instead.

## Multiple matches in Excel lookups

The problem is simple as illustrated below. Say you have a bunch of dates & locations. You want to find out corresponding date(s) for a location. If you use either VLOOKUP or INDEX+MATCH, you just get the first date, but you want them all.

In new version of Excel (2019), you can use awesome formulas like FILTER() to do exactly this, but most of us are still stuck in older version of Excel. So how to get all the matches?

## The trick – Use TEXTJOIN…

TEXTJOIN is a text combining function available on Excel 365. We can it to solve our multiple matches problem.

Let’s say our data is in a table named plan. We want to lookup the location in cell G7 and return all matching dates.

We can use below TEXTJOIN formula (you must press Ctrl+Shift+Enter) to get result as this is an array formula.

`=TEXTJOIN(", ",TRUE, IF(plan[Location]=G7,         TEXT(plan[Date],"dddd dd-mmm"),""))`

### How this multiple match formula works?

Let’s go from inside out.

1. IF(plan[Location]=G7 this part checks every location in the plan table and returns a bunch of TRUE or FALSE values. The end result would be an array like this. {FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE; TRUE;TRUE;TRUE; FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}
2. TEXT(plan[Date], “dddd dd-mmm”) this part takes all the dates in plan table and converts them to dddd dd-mmm format (ie 18/05/2019 becomes Saturday 18-May). The end result would be another array of dates formatted.
3. IF(plan[Location]=G7, TEXT(plan[Date],”dddd dd-mmm”),””) this entire IF formula results in either a bunch of formatted dates or blanks, based on whether plan[Location] matches G7 or not. So we get something like this. {“”;””;””;””;””;””;””;””;”Saturday 18-May”;”Sunday 19-May”;”Monday 20-May“;””;””;””;””;””;””;””;””}
4. TEXTJOIN(“, “,TRUE, IF()) this is the final part of the puzzle. TEXTJOIN takes individual bits of the array in #3 and combines them with delimiter , (comma space) but ignores any blanks (TRUE as second parameter). The final result is one text that goes like – Saturday 18-May, Sunday 19-May, Monday 20-May

### Why bother with TEXT(plan[Date], “dddd dd-mmm”)?

If you don’t use TEXT() to convert your dates, you get something like this instead – 43603, 43604, 43605. This is because Excel dates are really just numbers. So when you use them in any formula you just get the underlying number value. This is why TEXT() formula is so helpful.

Related: Top 10 tips for working with Excel date & time values.

## Still confused? Multiple Matches in Excel – Trick

Not sure how all of this works? Check out below video to understand this trick in detail. You can also watch this on my YouTube channel.

### HELP! I don’t have TEXTJOIN()

As mentioned earlier, TEXTJOIN is available in Excel 365 or 2019 + only. So if you are using an older version of Excel, you should use one of the below techniques to get multiple matches.

• Multiple occurrences in lookups – advanced tricks
• Lookup 2nd, 3rd matching items

And yeah, while you are polishing your lookup saw, why not also read these..

• Multiple conditions in lookup
• 2 way lookups
• 3 way (3D) lookups?

## How do you multiple match?

Do you use TEXTJOIN() or something else? Or do you just give up after first match? Please share your lookup tricks in the comments box.

The post VLOOKUP multiple matches – trick appeared first on Chandoo.org – Learn Excel, Power BI & Charting Online.