軟體: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