Martunis99
New Member
- Joined
- Aug 16, 2021
- Messages
- 19
- Office Version
- 2016
- Platform
- Windows
Hi guys,
So I created a function that sort of works like a VLOOKUP but for each criteria value returns multiple matches all concatenated and separated by comma (in the same cell).
Do you think this function is going to work fine?
Or does it need some adjustments?
Thank you.
The code:
So I created a function that sort of works like a VLOOKUP but for each criteria value returns multiple matches all concatenated and separated by comma (in the same cell).
Do you think this function is going to work fine?
Or does it need some adjustments?
Thank you.
The code:
Rich (BB code):
Public Function VlookupV2(Criteria As Range, Interval As Range, Column As Integer)
Dim Result As String
For i = 1 To Interval.Rows.Count
If Criteria.Value = Interval.Columns(1).Rows(i).Value Then
If InStr(Result, Interval.Columns(Column).Rows(i).Value) = 0 Then
Result = Result & Interval.Columns(Column).Rows(i).Value & ", "
End If
End If
Next i
Result = Left(Result, Len(Result) - 2)
VlookupV2 = Result
End Function