我是一个全新的编写宏,刚刚开始了解它是如何工作的。我需要将数据从一个工作簿复制到另一个工作簿,这是我想出的宏:
Option Explicit
Sub CopyMainTable()
Dim SourceWorkbook As Workbook
Dim DestWorkbook As Workbook
' Set references to the source and destination workbooks
Set SourceWorkbook = Workbooks("Monthly Report.xlsx")
Set DestWorkbook = Workbooks("ANNUAL REPORT.xlsx")
' Copy data from source to destination
SourceWorkbook.Sheets("SITE1").Range("B19:Av43").Copy Destination:=DestWorkbook.Sheets("SITE1").Range("B19")
Set SourceWorkbook = Nothing
Set DestWorkbook = Nothing
End Sub
字符串
问题是,当它运行时,它会出现一个运行时错误9:下标超出范围,我检查了两个工作簿上的单元格,它们确实一一匹配
我确保所有的名字都拼写正确,并检查了电池上的电池。
1条答案
按热度按时间9q78igpj1#
字符串