Private Sub Worksheet_Activate() Dim sh As Worksheet Dim a As Integer Dim R As Integer //在目錄工作表激活時,自動創建工作簿中除“目錄”工作表外所有工作表的目錄 R = Sheet1.[A65536].End(xlUp).Row a = 2 If Sheet1.Cells(2, 1) <> "" Then//判斷是否存在工作表目錄 Sheet1.Range("A2:A" & R).ClearContents End If For Each sh In Worksheets If sh.CodeName <> "Sheet1" Then Sheet1.Cells(a, 1).Value = sh.Name a = a + 1 End If Next End Sub