我想学习如何将单元格从已经打开的 Excel 工作簿复制到另一个文件。我不只是想要一个代码,我想要一个教程。我的问题是谷歌只给我论坛。有人可以推荐一个带视频的好教程吗?超链接会有所帮助。
问问题
72 次
1 回答
3
Option Explicit
Sub CopyFromOpenWorkbookToAnother()
'declare variables
Dim wkbCopy as Workbook, wkbPaste as Workbook
Dim wksCopy as Worksheet, wksPaste as Worksheet
Dim rngCopy as Range
'set variables -> change the names to suit your data needs
Set wkbCopy = Workbooks("WorkbookToCopyFrom.xls")
Set wkbPaste = Workbooks("WorkbookToCopyTo.xls")
Set wksCopy = wkbCopy.Sheets("SheetToCopy")
Set wksPaste = wkbPaste.Sheets("SheetToPaste")
Set rngCopy = wksCopy.Range("A1:A10") 'adjust to whatever range you need
rngCopy.Copy wksPaste.Range("A1") 'adjust to wherever you want to paste
End Sub
于 2013-01-15T19:00:06.153 回答