Hi everyone, I'm hoping someone can help me out. I am looking for a macro that will return vlookup multiple values in a single cell in excel. I have used the below one from Lewiy that was listed in another thread, but it is returning the value every time it is found in the source spreadsheet. Is there anyway to modify the below formula to add a comma between values, and to only return unique values once?
Function MYVLOOKUP(lookupval, lookuprange As Range, indexcol As Long)
Dim r As Range
Dim result As String
result = ""
For Each r In lookuprange
If r = lookupval Then
result = result & " " & r.Offset(0, indexcol - 1)
End If
Next r
MYVLOOKUP = result
End Function
Function MYVLOOKUP(lookupval, lookuprange As Range, indexcol As Long)
Dim r As Range
Dim result As String
result = ""
For Each r In lookuprange
If r = lookupval Then
result = result & " " & r.Offset(0, indexcol - 1)
End If
Next r
MYVLOOKUP = result
End Function