Link to home
Start Free TrialLog in
Avatar of Dokat
Dokat

asked on

VBA Lookup Problem

Hi,

I have the below code returning Run-Time Error 1004 - Unable to get the Vlookup property of worksheetfunction class error. I noticed issue happens when lookupvalue is not in lookup range. Can anyone help solve this problem?

Here is the code and higlighted line
cl.Offset(, 1) = Application.WorksheetFunction.Vlookup(cl, LookupRange, LookupColNum, ExactMatch)

Open in new window


Sub LookupTier()
Dim LookupRange As Range
Dim LookupValue As Range

Dim cl As Range

    Set LookupValue = ActiveSheet.Range("CG:CG")

    Set LookupRange = ActiveSheet.Range("DE:DF")
    
    LookupColNum = 2
    
    ExactMatch = False
    
    For Each cl In LookupValue
        If cl.Value <> "" Then
            cl.Offset(, 1) = Application.WorksheetFunction.Vlookup(cl, LookupRange, LookupColNum, ExactMatch)
              On Error Resume Next
   
    On Error GoTo 0

        End If
    Next cl
    
End Sub

Open in new window

Topline-05192017.xlsb
ASKER CERTIFIED SOLUTION
Avatar of Shums Faruk
Shums Faruk
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dokat
Dokat

ASKER

Perfect. Thank you so much