I am doing a looping vlookup on the same worksheet but I am getting Runtime Error: 1004: Unable to get the Vlookup property of the WorksheetFunction class with this code:
Sub Test()
Dim d As Long
Dim lastrowx2 As Long
lastrowx2 = Worksheets("WS").Cells(Rows.Count, 1).End(xlUp).Row
For d = 2 To lastrowx2
Worksheets("WS").Cells(d, 16).Value = _ 'cell where the lookup value will be placed
Application.WorksheetFunction.VLookup( _ 'vlookup function
Worksheets("WS").Cells(d, 15).Value, _ 'value to look for
Worksheets("WS").Range("X:Y"), 2, 0) 'range and column to look
Next
End Sub
Am I doing something wrong here?
d
it can't findWorksheets("WS").Cells(d, 15).Value
in columnX
. – Aneta