Anyone knows why (Copy - Destination) does not work but Pastespecial does? What is the most efficient way to copy from one table in workbook 1 to another table in workbook 2?
Code:
Sub Import_data()
Dim wb As Workbook, wb2 As Workbook
Dim ws As Worksheet
Dim vFile As Variant
Application.ScreenUpdating = False
'Set target workbook
Set wb = ActiveWorkbook
'Open the source workbook
vFile = Application.GetOpenFilename("Excel-files,*.xlsx", _
1, "Select Source File To Open", , False)
'if the user didn't select a file, exit sub
If TypeName(vFile) = "Boolean" Then Exit Sub
Workbooks.Open vFile
'Set source workbook
Set wb2 = ActiveWorkbook
'Copy data from a table in the source workbook to another table in the target workbook
On Error Resume Next
wb.Sheets("sheet1").Range("tbTARGET[Number]").Copy Destination:=wb2.Sheets("sheet1").Range("tbSOURCE[Number]").Range
wb.Sheets("sheet1").Range("tbTARGET[Date]").Copy Destination:=wb2.Sheets("sheet1").Range("tbSOURCE[Date]").Range
wb2.Sheets("sheet1").Range("tbSOURCE[Name]").Copy
wb.Sheets("Sheet1").Range("tbTARGET[Name]").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
wb2.Close savechanges:=False
Application.ScreenUpdating = True
End Sub