I borrowed this VBA solution from extendoffice.com. It's very simple, easy to set up, and worked really well for my situation.
My scenario -
- Sheet 1 contains the lookup value in column A where I want the formula results in column B.
- Sheet 2 contains the table array in columns A and B where column A is again the lookup value and column B contains the values to be returned in the results.
First, press ALT+F11 to bring up the VBA editor.
Second, paste this Function into Module1 within the VBA editor:
Function MYVLOOKUP(pValue As String, pWorkRng As Range, pIndex As Long)
'Updateby Extendoffice
Dim rng As Range
Dim xResult As String
xResult = ""
For Each rng In pWorkRng
If rng = pValue Then
xResult = xResult & ", " & rng.Offset(0, pIndex - 1) 'I changed EO's delimiter from a space to a comma+space.
End If
Next
If Left(xResult, 2) = ", " Then
xResult = Right(xResult, Len(xResult) - 2) 'This removes any leading commas that make it into the results.
Else
'All is well in the world!
End If
MYVLOOKUP = xResult
End Function
Third, double click on the cell you want the multi-results in and paste this formula.
=MYVLOOKUP(A2, 'SheetName'!A1:B1816, 2)
Fourth, edit the formula to fit your spreadsheet.
- A2 - The lookup value that will be compared against the other list.
- 'SheetName'!A1:B1816 - Replace SheetName with the name of the sheet your other list is on and replace A1:B1816 with the full range of values that are both being looked up and returned.
- 2 - If the values you want returned in your results are in a column other than B, replace '2' with the column that contains the values you want returned in your results.
You're done! If you did everything correctly (and you don't have any Trust Center settings blocking VBA code) then it should look like a VLOOKUP returned multiple results in a single cell.