im getting en 424 error when im trying to run this code in vba :
Sub Procurar()
ThisWorkbook.Activate
Sheets("Sheet").Select
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Call OpenWorkbook
For i = 1 To Selection.Rows.Count
ID = Cells(i, 1).Value
Cells(i, 6).Value = Application.WorksheetFunction.VLookup(ID, UnidadesWb.Sheets("a").Range("A:B"), 2, False)
On Error Resume Next
Next i
End Sub
Sub OpenWorkbook()
Dim UnidadesWb As Workbook
Set UnidadesWb = Workbooks.Open("C:\Users\h1ckzz\Desktop\PetLand\Workbooks\NewUNIDADES6.xlsx")
End Sub
Error is on the :
Cells(i, 6).Value = Application.WorksheetFunction.VLookup(ID, UnidadesWb.Sheets("a").Range("A:B"), 2, False)
Can anyone help me please ? Ty