ExcelVBAで目次を作成する

ちなみに、「Excel vba 目次」とかで探せばもっと良記事がいろいろ出てきます。
自分でいろいろ考えながら作ったので残しておきます。

'全シートを目次とするシートをはじめのシートに追加する
Sub createIndex()
    Dim sheet As Worksheet
    Dim row As Integer
    Dim indexExists As Boolean
    Dim rc As Integer
    Dim i As Integer
            
    indexExists = False
    For Each sheet In Worksheets
        If sheet.Name = "index" Then
            indexExists = True
            rc = MsgBox("indexは既に存在します。処理を続けますか?(処理を続ける場合、indexシートは上書きされます。)", vbYesNo + vbQuestion, "確認")
        End If
    Next sheet
    
    If indexExists And rc = 7 Then
        GoTo quit
    End If
    
    If Not indexExists Then
        Worksheets.Add before:=Worksheets(1)
        ActiveSheet.Name = "index"
    Else
        Worksheets("index").Activate
        ActiveSheet.Cells.Clear
    End If
        
    row = 1
    For Each sheet In Worksheets
        'indexシート自体が目次に含まれることを防ぐ
        If sheet.Name = "index" Then
            GoTo continue
        End If
        '目次を追加し、ハイパーリンクを設定します
        ActiveSheet.Cells(row, 1).Value = sheet.Name
        ActiveSheet.Hyperlinks.Add _
        anchor:=Range("A" & row), _
        Address:="", _
        SubAddress:=sheet.Name & "!" & "A1", _
        TextToDisplay:=sheet.Name
        
        row = row + 1
continue:
    Next sheet
    
quit:
    
End Sub