软件:EXCEL
版本: office365
请教一下想
这里执行时原本没有问题
Sub EX()
Dim iPath As String
Dim NewName As String
Dim ibook As Workbook
Application.ScreenUpdating = False
iPath = "C:\Users\ifye0\Desktop\" '指定路径
NewName = Format(Now, "yyyymmddhhmmss") & CStr(Sheets("工作表1").Range("A1"))
Set ibook = ActiveWorkbook
With Workbooks.Add: ibook.Activate
Sheets("工作表1").Range("A1:G10").Copy .Sheets(1).Range("A1"):
.Sheets(1).Name = "工作表1"
.SaveAs iPath & NewName: .Close True
End With: Set ibook = Nothing
End Sub
但是在
Sheets("工作表1").Range("A1:G10").Copy .Sheets(1).Range("A1"):
.Sheets(1).Name = "工作表1"
加入下面这一段就会秀出ERROR
Sheets("工作表2").Range("A1:G10").Copy .Sheets(2).Range("A1"):
.Sheets(2).Name = "工作表2"
执行阶段错误9
阵列索引超出范围
请问是为什么
感谢
https://imgur.com/a/TzYt0Qn
https://imgur.com/IliFurp