• 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

  • 相关阅读:
    BRAFT EDITOR富文本编辑器
    小程序
    单元测试之道读书笔记(二)
    单元测试之道读书笔记(一)
    Blend学习网址
    2014年要读的10本书
    程序员一生必读的书籍
    WPF中PasswordBox控件无法绑定Password属性解决办法
    异步方式向WPF ListBox控件中一条一条添加记录
    10中适合编程的字体
  • 原文地址:https://www.cnblogs.com/lxxlovekang/p/4342265.html
Copyright © 2020-2023  润新知