从一个工作簿复制并粘贴到另一个工作簿我编写了以下代码,并不断地看到以往的课堂教学方法失败了..我试图克服这个问题,但似乎什么也没有解决。我试图从一本工作簿中复制一整张工作表,并将其粘贴到另一本工作簿中:Set x = Workbooks.Open(" path to copying book ")Workbooks.Open(" path to copying book ").Activate
Range("A1").Select'Cells.SelectSelection.CopySet y = Workbooks.Open("path to pasting book")Workbooks.Open("Path to pasting book").ActivateWith y
Sheets("sheetname").Cells.Select
Range("A1").PasteSpecial 'Sheets("sheetname").PasteSpecial
.CloseEnd WithWith x .CloseEnd With
2 回答
12345678_0001
TA贡献1802条经验 获得超5个赞
Dim x As Workbook, y As WorkbookDim ws1 As Worksheet, ws2 As WorksheetSet x = Workbooks.Open("path to copying book") Set y = Workbooks.Open("path to pasting book")Set ws1 = x.Sheets("Sheet you want to copy from") Set ws2 = y.Sheets("Sheet you want to copy to")ws1.Cells.Copy ws2.cells y.Close Truex.Close False
ws1.Range("Address").Copy: ws2.Range("A1").PasteSpecial xlPasteValues y.Close Truex.Close False
:
.Copy
Statement Separating
Object.PasteSpecial
添加回答
举报
0/150
提交
取消