I am trying to write a code to open a workbook titled 64A, copy columns a, c:f, close and then paste the data into the workbook with the macro in it. I am comfortable using formulas in Excel but am just starting to learn VBA. I have come up with the script below through many internet searches. I can get it to copy one column but when I try to make it copy more than one column it gives me error messages. Any help would be appreciated.
Thanks,
Craig
Sub Macro2()
'Assign variable name to Target workbook
Var1 = ActiveWorkbook.Name
'Assign variable name to Target range
Var1R = "A1"
'Open Source WorkBook
Application.Workbooks.Open ("C:........\64A.xlsx")
'Assign variable name to Source workbook
Var2 = ActiveWorkbook.Name
Var2R = 1
'Copy from Source to Target
Sheets(Var2R).Columns("C").EntireColumn.Copy _
Destination:=Workbooks(Var1).Sheets("Sheet1").Range(Var1R)
'Close Source WorkBook wo/Save
Workbooks(Var2).Close False
End Sub
Thanks,
Craig
Sub Macro2()
'Assign variable name to Target workbook
Var1 = ActiveWorkbook.Name
'Assign variable name to Target range
Var1R = "A1"
'Open Source WorkBook
Application.Workbooks.Open ("C:........\64A.xlsx")
'Assign variable name to Source workbook
Var2 = ActiveWorkbook.Name
Var2R = 1
'Copy from Source to Target
Sheets(Var2R).Columns("C").EntireColumn.Copy _
Destination:=Workbooks(Var1).Sheets("Sheet1").Range(Var1R)
'Close Source WorkBook wo/Save
Workbooks(Var2).Close False
End Sub