I am doing a reverse vlookup on a table. The object is to find a value from the table and return the corresponding number in the first column. I used a code I found online:
Function RL(ModK As Range, LookupTable As Range)
HRow = LookupTable.Rows(1).Row - 1
HCol = LookupTable.Columns(1).Column - 1
RL = ""
For Each cell In LookupTable
If cell.Value = ModK.Value Then
RL = RL & Cells(cell.Row, 1).Value
End If
Next cell
End Function
It works great except that the Modk value that is passed to the function must match a value in the LookupTable otherwise I get an error or blank.
My question is : Is there a way to return the closest match of a value being passed from the LookupTable ?
Thanks
Function RL(ModK As Range, LookupTable As Range)
HRow = LookupTable.Rows(1).Row - 1
HCol = LookupTable.Columns(1).Column - 1
RL = ""
For Each cell In LookupTable
If cell.Value = ModK.Value Then
RL = RL & Cells(cell.Row, 1).Value
End If
Next cell
End Function
It works great except that the Modk value that is passed to the function must match a value in the LookupTable otherwise I get an error or blank.
My question is : Is there a way to return the closest match of a value being passed from the LookupTable ?
Thanks