Sub ブック_INDEX()
'シートのINDEXを作成する。 Dim s As Worksheet Dim i As Integer Dim w_sheet As Worksheet '■■■■■■■■■■■■■■■■■ Application.DisplayAlerts = False Application.EnableEvents = False Application.ScreenUpdating = False Application.Calculation = xlCalculationManual '■■■■■■■■■■■■■■■■■ On Error Resume Next Sheets("INDEX").Delete On Error GoTo 0 Sheets.Add Before:=Sheets(1) Set s = ActiveSheet s.Name = "INDEX" s.Cells.ColumnWidth = 2 Application.StatusBar = "01" DoEvents i = 2 For Each w_sheet In Sheets ' Application.StatusBar = "ハイパーリンク作成 " & i & "/" & Sheets.Count + 1 s.Cells(i, 1) = w_sheet.Index s.Cells(i, 3) = "'" & w_sheet.Name ActiveSheet.Hyperlinks.Add Anchor:=s.Cells(i, 3), Address:="", SubAddress:="'" & s.Cells(i, 3).Value & "'!A1", TextToDisplay:="'" & s.Cells(i, 3).Value s.Cells(i, 3).Font.Underline = xlUnderlineStyleNone
If w_sheet.Visible = xlSheetHidden Then s.Cells(i, 3).Interior.ColorIndex = 15 '灰色 End If s.Cells(i, 4).Value = w_sheet.Cells.SpecialCells(xlCellTypeLastCell).row s.Cells(i, 5).Value = w_sheet.Cells.SpecialCells(xlCellTypeLastCell).Column i = i + 1 Next w_sheet Application.StatusBar = "02" DoEvents For Each w_sheet In Sheets If w_sheet.Name <> "INDEX" Then If w_sheet.Range("A1") = "※" Then w_sheet.Range("A1") = "" End If w_sheet.Activate w_sheet.Range("A1").Select End If i = i + 1 Next w_sheet Application.StatusBar = "03" DoEvents Sheets("INDEX").Activate For Each w_sheet In Sheets w_sheet.Select Application.ScreenUpdating = True Application.StatusBar = "03 " & w_sheet.Name DoEvents Application.ScreenUpdating = False ActiveWindow.LargeScroll ToLeft:=99 ActiveWindow.LargeScroll Up:=99 w_sheet.Range("A1").Select With w_sheet.PageSetup .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = 1 End With With w_sheet.PageSetup .LeftHeader = "&F" .CenterHeader = "&A" .RightHeader = "ページ &P" .TopMargin = Application.CentimetersToPoints(2) .BottomMargin = Application.CentimetersToPoints(1) .LeftMargin = Application.CentimetersToPoints(1.5) .RightMargin = Application.CentimetersToPoints(1) .HeaderMargin = Application.CentimetersToPoints(1) .FooterMargin = Application.CentimetersToPoints(0.5) End With Next w_sheet
Application.StatusBar = "04" DoEvents With s .Range("A1").Value = "ページ" .Range("A1").HorizontalAlignment = xlRight .Range("C1").Value = "シート" .Range("D1").Value = "行数" .Range("E1").Value = "列数" .Tab.ColorIndex = 3 .PageSetup.PrintArea = "A1:C" & .UsedRange.Rows.Count End With
Application.StatusBar = "05" DoEvents s.Activate s.Cells.Font.Name = "Meiryo UI" s.Cells.EntireColumn.AutoFit Application.StatusBar = "06" DoEvents Rows("2:2").Select ActiveWindow.FreezePanes = True Columns("B:B").Select Selection.AutoFilter s.Cells(1, 1).Select
'■■■■■■■■■■■■■■■■■ Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True Application.EnableEvents = True Application.DisplayAlerts = True Application.StatusBar = False '■■■■■■■■■■■■■■■■■
End Sub