(Solved) – Vlookup in VBA from different sheets – coding error

  • by

i am new to VBA. I got this code but when it runs, it shows this error message :

Wrong number of argument or invalid property assignment.

This is my code when i copied it from somewhere and editing myself :

Sub cl_macro2() 
    cl_macro2 macro '
    Dim Concur As Worksheet, SunAccCode As Worksheet
    Dim ConcurLastRow As Long, SunAccCodeLastRow As Long, x As Long
    Dim SunAccCodeRng As Range

    Set Concur = ThisWorkbook.Worksheets("Concur")
    Set SunAccCode = ThisWorkbook.Worksheets("SunAccCode")

    ConcurLastRow = Concur.Range("I" & Rows.Count).End(xlUp).Row
    SunAccCodeLastRow = SunAccCode.Range("A" & Rows.Count).End(xlUp).Row

    Set SunAccCodeRng = SunAccCode.Range("A1:C" & SunAccCodeLastRow)

    For x = 2 To ConcurLastRow
    On Error Resume Next
    Concur.Range("J" & x).Value = Application.WorksheetFunction.VLookup(Concur.Range("I" & x).Value, SunAccCodeRng, 3, 0)

    Next x

End Sub 

Leave a Reply

Your email address will not be published. Required fields are marked *