-
Viorel 119.9K Reputation points
2022-07-02T05:19:35.343+00:00 Try removing "(3)".
Merge two tables through macro
I am trying to append two distinct tables with common column names into another table. Below is the code I am using
Sub Button1_Click()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet
Dim LastRow As Long
Set pasteSheet = Worksheets("Sheet3")
'first copy
Set copySheet = Worksheets("Sheet1")
copySheet.Range("table1").Copy Destination:=pasteSheet.Range("table3").End(xlUp).Offset(1)
'move to the next empty row
'LastRow = pasteSheet.Range("table3").End(xlUp).Row
'second copy
Set copySheet = Worksheets("Sheet2")
copySheet.Range("table2").Copy Destination:=pasteSheet(3).Range("table3").End(xlUp).Offset(1)
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
However, I am getting the error 'Object does not support this property or method' and only contents from table 1 are getting pasted.