• Excel Skill---Generate Table of Contents based on Sheet Name (根据Sheet名称产生目录)


    Sub mulu()
    On Error GoTo Tuichu
    Dim i As Integer
    Dim ShtCount As Integer
    Dim SelectionCell As Range

    ShtCount = Worksheets.Count
    If ShtCount = 0 Or ShtCount = 1 Then Exit Sub
    Application.ScreenUpdating = False
    For i = 1 To ShtCount
    If Sheets(i).Name = "Inventory" Then
    Sheets("Inventory").Move Before:=Sheets(1)
    End If
    Next i
    If Sheets(1).Name <> "Inventory" Then
    ShtCount = ShtCount + 1
    Sheets(1).Select
    Sheets.Add
    Sheets(1).Name = "Inventory"
    End If
    Sheets("Inventory").Select
    Columns("B:B").Delete Shift:=xlToLeft
    Application.StatusBar = "Generating Inventory…………WAITING!"
    For i = 2 To ShtCount
    ActiveSheet.Hyperlinks.Add Anchor:=Worksheets("Inventory").Cells(i, 2), Address:="", SubAddress:= _
    "'" & Sheets(i).Name & "'!R1C1", TextToDisplay:=Sheets(i).Name
    Next
    Sheets("Inventory").Select
    Columns("B:B").AutoFit
    Cells(1, 2) = "Inventory"
    Set SelectionCell = Worksheets("Inventory").Range("B1")
    With SelectionCell
    .HorizontalAlignment = xlDistributed
    .VerticalAlignment = xlCenter
    .AddIndent = True
    .Font.Bold = True
    .Interior.ColorIndex = 34
    End With
    Application.StatusBar = False
    Application.ScreenUpdating = True
    Tuichu:
    End Sub

  • 相关阅读:
    Bzoj1597 [Usaco2008 Mar]土地购买
    Bzoj1500 [NOI2005]维修数列
    模拟7 题解
    模拟6 题解
    模拟5 题解
    远古杂题 2
    远古杂题 1
    [NOIP2013]华容道 题解
    奇袭 CodeForces 526F Pudding Monsters 题解
    图论杂题
  • 原文地址:https://www.cnblogs.com/lxxlovekang/p/4342265.html
Copyright © 2020-2023  润新知