我有两本excel工作簿。我试图将工作表从一个工作簿复制到另一个工作簿。 之后我想关闭我复制过的工作簿。 到目前为止我做了什么:
Sub copy()
Workbooks.Open filename:= _
"C:\2016.xlsm"
ActiveWorkbook.Sheets("Grafic").Select
Selection.Copy Destination:=Workbooks("C:\Grafic.xlsx").Sheets("Sheet1").Range("A1")
End Sub
感谢。
答案 0 :(得分:1)
也许这有帮助
Option Explicit
Sub CopyIt()
Dim wb As Workbook
Dim copyWb As Workbook
Dim wks As Worksheet
Dim fileName As String, sheetName As String
fileName = "... complete filename ..."
sheetName = "... sheet name ..."
Set wb = Workbooks.Open(fileName:=fileName)
Set wks = wb.Sheets(sheetName)
Set copyWb = ThisWorkbook ' the workbook you would like to copy to
wks.copy before:=copyWb.Sheets(1)
wb.Close False
End Sub
答案 1 :(得分:0)