highly appreciate your help on this. I'm trying to vlookup from worksheet A to worksheet B and i did find it the example code in this forum but suddenly got error - Run-time error '1004': Method 'Range' of object_Worksheet' failed
Sub Sample()
Dim wbThis As Workbook, wbThat As Workbook
Dim wsThis As Worksheet, wsThat As Worksheet
Dim aCell As Range
Set wbThis = ThisWorkbook
'~~> Let's say this is the sheet where you want the result
'~~> Change name as applicable
Set wsThis = wbThis.Sheets("Sheet1")
'~~> Change path as applicable
Set wbThat = Workbooks.Open("C:\Users\Fahmi\Desktop\VBA TESTING\Template.xlsx")
Set wsThat = wbThat.Sheets("CtyAccesCode")
With wsThis
For Each aCell In .Range("H2:H" & LastRow)
If Len(Trim(.Range("AD" & aCell.Row).Value)) <> 0 Then
.Cells(aCell.Row, 28) = Application.WorksheetFunction.VLookup( _
aCell.Value, wsThat.Range("A1:B13"), 2, 0)
End If
Next aCell
End With
wbThat.Close (False)
End Sub
and the error on this line
thanks in advance!