目錄
How to Create a Dynamic Table of Contents in Excel
首頁 系統教程 Windows系列 如何在Excel中創建動態目錄

如何在Excel中創建動態目錄

Mar 24, 2025 am 08:01 AM

A table of contents is a total game-changer when working with large files – it keeps everything organized and easy to navigate. Unfortunately, unlike Word, Microsoft Excel doesn’t have a simple “Table of Contents” button that adds this handy feature and updates it automatically. No, you’ll have to roll up your sleeves and create a dynamic table of contents yourself. This table will automatically update and contain clickable links, allowing you to add and remove sheets – as well as jump between them – with ease. This guide has all the info you need to create a dynamic table of contents in Excel.

How to Create a Dynamic Table of Contents in Excel

Technically, there are three ways to create a dynamic table of contents (TOC) in Excel. However, only one of them guarantees a fully automated TOC, and that’s Visual Basic for Applications or VBA for short – Microsoft’s native programming language. The other two – traditional formulas and Power Query – will give you a semi-dynamic table of contents in Excel – one that either doesn’t include clickable links or doesn’t update automatically. Since we’re after a fully dynamic Excel table of contents, we’ll use VBA.

If you aren’t particularly VBA-savvy; don’t worry – you just need to follow a few steps. But first – let’s create our table of contents.

Step 1: Click on the “Insert Worksheet” button next to your sheets at the bottom.

如何在Excel中創建動態目錄

Step 2: Name the sheet “Table of Contents.”

如何在Excel中創建動態目錄

Step 3: Drag the sheet to the first position for better navigation.

如何在Excel中創建動態目錄

Step 4: Enter the names of your sheets in Column A of the “Table of Contents” sheet.

如何在Excel中創建動態目錄

And voilà – you’ve got your table of contents. You can play with the aesthetics of this TOC later – now, we need to make it dynamic. To do so, we’ll need the help of the VBA Editor – a built-in Excel tool that lets you write and run custom codes.

Step 1: Press “Alt + F11” to open the VBA Editor.

如何在Excel中創建動態目錄

Step 2: Go to the “Insert” tab at the top.

如何在Excel中創建動態目錄

Step 3: Select “Module” from the dropdown menu.

如何在Excel中創建動態目錄

Step 4: Copy and paste the following VBA code:

Sub CreateTOC()

    Dim ws As Worksheet

    Dim toc As Worksheet

    Dim i As Integer

    ‘ Check if TOC sheet already exists, delete if it does

    On Error Resume Next

    Set toc = ThisWorkbook.Sheets(“Table of Contents”)

    On Error GoTo 0

    If Not toc Is Nothing Then Application.DisplayAlerts = False: toc.Delete: Application.DisplayAlerts = True

    ‘ Create new TOC sheet

    Set toc = ThisWorkbook.Sheets.Add(Before:=ThisWorkbook.Sheets(1))

    toc.Name = “Table of Contents”

    ‘ Set up TOC header

    toc.Cells(1, 1).Value = “Table of Contents”

    toc.Cells(1, 1).Font.Bold = True

    toc.Cells(1, 1).Font.Size = 14

    ‘ Loop through all sheets and add hyperlinks

    i = 2

    For Each ws In ThisWorkbook.Sheets

        If ws.Name <> “Table of Contents” Then

            toc.Hyperlinks.Add Anchor:=toc.Cells(i, 1), _

                Address:=””, _

                SubAddress:=”‘” & ws.Name & “‘!A1”, _

                TextToDisplay:=ws.Name

            i = i + 1

        End If

    Next ws

    ‘ Adjust column width

    toc.Columns(“A”).AutoFit

 End Sub

如何在Excel中創建動態目錄

Step 5: Hit “F5” to run the code.

Step 6: Exit the VBA Editor.

You’ll notice your Excel table of contents is now clickable.

如何在Excel中創建動態目錄

To automatically update your table of contents after changes, you just need to repeat Steps 1 to 6. This will add any new sheets to the list or remove the ones you deleted.

如何在Excel中創建動態目錄

以上是如何在Excel中創建動態目錄的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Stock Market GPT

Stock Market GPT

人工智慧支援投資研究,做出更明智的決策

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

如何播放Bing Homepage測驗並獲勝(快速指南) 如何播放Bing Homepage測驗並獲勝(快速指南) Sep 17, 2025 pm 08:39 PM

閱讀我們的披露頁面,以了解如何幫助MSPOWERUSER維持編輯團隊閱讀Morethe bing bing homepage Quiz提供了一種有趣的方式來挑戰您的知識,同時可能會贏得獎勵。雖然沒有萬無一失的方法

新指南:修復Windows打印機問題和假台器件問題 新指南:修復Windows打印機問題和假台器件問題 Aug 29, 2025 am 08:12 AM

ifyourwindowsprinteris notworking,turtheSesteps:1.RestthePrintSpoolerService.2.runthebuilt-inprintrubloubloubleShooter.3.ReinstallThePrInterDriver.4.MerallyCearCearStuckPrintJobs.5.usecomppromptPromptPromptTormptTormptTorMptTortTorpRintingComponents。

套娃系統教程:多系統怎麼玩? Ubuntu安裝實戰 套娃系統教程:多系統怎麼玩? Ubuntu安裝實戰 Sep 02, 2025 pm 05:09 PM

昨天已經介紹了VMwareWorkstationPro的安裝方法,但由於錄製時間的限制未能及時發布,今天為大家帶來更新! ! !歡迎喜歡嘗試新事物的朋友們來安裝下面的Ubuntu系統。 Ubuntu同樣是一款非常優秀的操作系統,儘管不像Windows那樣直觀易用,例如許多應用需要通過命令行來下載,這對新手來說可能有一定的難度,不過大家可以嘗試體驗一下。以下為大家推薦幾個下載系統鏡像的網站:Windows操作系統鏡像及工具和資源:https://msdn.itellyou.cn/Linux操作系統官方網

win10專業版多少錢 win10專業版2025年價格介紹 win10專業版多少錢 win10專業版2025年價格介紹 Sep 01, 2025 pm 06:21 PM

如果你正在考慮購買Windows 10專業版,那麼了解其價格是非常重要的。 Windows 10專業版不僅為用戶提供了豐富的功能和強大的安全性,還能夠滿足企業和個人用戶的多種需求。那麼,Win10專業版2025年的價格是多少呢?本文將為你詳細介紹Windows 10專業版的價格信息,幫助你做出明智的購買決策。

如果Win11打印機不起作用該怎麼辦? Win11中打印機連接問題的解決方案 如果Win11打印機不起作用該怎麼辦? Win11中打印機連接問題的解決方案 Sep 01, 2025 am 08:19 AM

IfyourWindows11printerisn'tresponding,trythesesteps:1.Checkpower,connections,andprinterstatus.2.RestartthePrintSpoolerserviceandclearspoolfiles.3.Reinstallthelatestprinterdriverfromthemanufacturer.4.RunWindowsPrinterTroubleshooter.5.Manuallyaddthepri

重裝系統win10步驟和詳細教程 2025最新版 重裝系統win10步驟和詳細教程 2025最新版 Sep 01, 2025 pm 06:39 PM

重裝系統Win10是一項常見的電腦維護任務,能夠有效解決系統運行緩慢、軟件衝突等問題。本文將為你提供一份詳細的重裝系統Win10步驟和詳細教程,確保你在操作過程中不會遇到任何困難。無論你是電腦新手還是老手,都能輕鬆完成重裝系統的任務。讓我們開始吧!

如何更改Windows中的文件權限? 如何更改Windows中的文件權限? Sep 16, 2025 am 12:44 AM

tomanagefileaccessinwindows,Advistermissionsviafileproperties'securitytab,usecaclsoricaclsclsclsclscommandsinanelevatedCommandPromptForAmptforAdvancedControl,ortakeWanceControl,ortakeownerpralfirstifrstifrstifrstifrstifrastirals.applychangescoreflychangescoreforfullychangescorefoensureproperpoperacsccsccessrightsigrtersirr。

如何在PC上下載,安裝和更新Roblox(快速指南) 如何在PC上下載,安裝和更新Roblox(快速指南) Sep 18, 2025 pm 08:00 PM

閱讀我們的披露頁面,以了解如何幫助Mspoweruser維持編輯團隊閱讀MoreroBlox已成為使用最廣泛的在線遊戲平台之一,並且在計算機上將其啟動並運行很簡單。這個分步g

See all articles