请问我下面这个程序怎么总提示下标越界
Sub 获取工作表名称()
Columns("A:A").Select
Selection.ClearContents
i = 1
For Each sh In Sheets
Cells(i, 1) = sh.Name
i = i + 1
Sheets("目录").Hyperlinks.Add Anchor:=Sheets("目录").Cells(i, 1), _
Address:="", SubAddress:="'" & Sheets(i).Name & "'!A1", _
TextToDisplay:=Sheets(i).Name, ScreenTip:="单击打开:" & Sheets(i).Name
Next
End Sub
Function IsSht(ShtName As String)
On Error Resume Next
Dim sht As Worksheet
Set sht = Sheets(ShtName)
IsSht = (Err = 0)
End Function
Sub 返回目录()
'如果有“目录”则返回“目录”工作表
If IsSht("目录") Then Sheets("目录").Select
End Sub