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