I have a Macro for excel I found online to create a 'myvlookup' function which allows to lookup all instances of a number in a range and return a specified corresponding column; multiple instances if necessary. I've gotten the macro and respective myvlookup to work for my needs but I'd like an explanation of the logic/meanings behind how this code works. Code is below and any information would be helpful. P.S I'm code illiterate, so don't assume I know anything lol. Thanks!
Function MYVLOOKUP(pValue As String, pWorkRng As Range, pIndex As Long)
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)
End If
Next
MYVLOOKUP = xResult
End Function
Bookmarks