我一直在尝试编写一个宏来将“Sheet1”从一个工作簿复制到另一个工作簿,但我不断收到运行时错误“9”:下标超出范围。
Sub CopySheetToOtherWbk()
Dim CopyFromBook As Workbook
Dim CopyToWbk As Workbook
Dim ShToCopy As Worksheet
Set CopyFromBook = Workbooks("AllBugs.xlsx")
Set ShToCopy = CopyFromBook.Worksheets("Sheet1")
Set CopyToWbk = Workbooks("YourFriendlyNeighborhoodTemplateWorksheet.xlsx")
ShToCopy.Copy After:=CopyToWbk.Sheets(CopyToWbk.Sheets.Count)
End Sub
突出显示的行是“Set CopyFromBook = Workbooks("AllBugs.xlsx")”。不知道我在这里做错了什么。VBA 相对较新。任何帮助表示赞赏。