i am trying to create a macro in excel to copy a certain data range and paste it at the end row of the table(after expanding it). The table is located in another workbook. Here is the code I am trying to execute -
Sub Macro9()
Dim mySel As Range
Dim ws As Worksheet
Dim loTable As ListObject
Dim LastRow As Long
ActiveSheet.Select
Set mySel = Selection.EntireRow
mySel.Copy
Workbooks.Open Filename:="/Users/achintyamittal/Desktop/list.xlsx"
Set ws = Sheets("Sheet1")
'Define Table Object
Set loTable = ws.ListObjects("Truck_List")
loTable.ListRows.Add
Selection.ListObject.ListRows.Add AlwaysInsert:=False
LastRow = ws.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
Range("A" & LastRow).Select
Selection.PasteSpecial Paste:=xlPasteValues
End Sub
I am getting the error in the last line(PasteSpecial). I wanted to know how to solve to this error.