我编写了以下脚本,但运行时错误下标超出范围。谁能帮我解决这个问题?(msgbox 用作调试器)
提前致谢。
Sub newbook()
Dim bk As Workbook, sht As Worksheet
MsgBox ("variables created")
Set bk = Workbooks.Add
MsgBox ("book is set")
With bk
.Title = "NewBook"
.SaveAs Filename:="NewBook.xls"
End With
MsgBox ("Book is created")
Set sht = bk.Sheets.Add
MsgBox ("sheet is set")
bk.Sheets(1).Name = "Hello 1"
bk.Sheets(2).Name = "Hello 2"
bk.Sheets(3).Name = "Hello 3"
bk.Sheets(4).Name = "Hello 4"
MsgBox ("everything is completed")
End Sub