Saturday, October 29, 2011

F2 + F9

Reverse Vlookup

Reverse Vlookup... (much awaited formula)...
now copy paste below code in your VB script.. and enjoy the RVLOOKUP

--------------------------------------------------------------------------------------

Function RLOOKUP(Look_Value As Variant, Array1 As Range, Array2 As Range, Col_num As Integer)

On Error Resume Next
Dim ValFound

With WorksheetFunction
Set Array1 = .Range(Array1.Address)
Set Array2 = .Range(Array2.Address)
ValFound = .Index(Array2, .Match(Look_Value, Array1, 0), Col_num)
End With

If IsError(WorksheetFunction.Match(Look_Value, Array1, 0)) Or Look_Value = "" Then
ValFound = CVErr(xlErrNA)
RLOOKUP = ValFound
Else
RLOOKUP = ValFound
End If

Set Array1 = Nothing
Set Array2 = Nothing

End Function