search
HomeSystem TutorialWindows SeriesHow to Create a Dynamic Table of Contents in Excel

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.

How to Create a Dynamic Table of Contents in Excel

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

How to Create a Dynamic Table of Contents in Excel

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

How to Create a Dynamic Table of Contents in Excel

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

How to Create a Dynamic Table of Contents in 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.

How to Create a Dynamic Table of Contents in Excel

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

How to Create a Dynamic Table of Contents in Excel

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

How to Create a Dynamic Table of Contents in 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

How to Create a Dynamic Table of Contents in 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.

How to Create a Dynamic Table of Contents in 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.

How to Create a Dynamic Table of Contents in Excel

The above is the detailed content of How to Create a Dynamic Table of Contents in Excel. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
8 Ways to Clear the Clipboard on Windows 118 Ways to Clear the Clipboard on Windows 11Apr 21, 2025 pm 12:13 PM

This guide provides multiple ways to clear your Windows 11 clipboard, ensuring your copied data remains private. Your clipboard stores various items, including text, images, and videos. Let's explore several methods to erase its contents. Method 1:

Logitech's G515 Lightspeed keyboard is 25% offLogitech's G515 Lightspeed keyboard is 25% offApr 21, 2025 pm 12:06 PM

Logitech G515 Lightspeed TKL Mechanical Gaming Keyboard Review The Logitech G515 Lightspeed TKL uses low profile keys and feels very similar to the Apple Magic Keyboard, but has an additional mechanical switch, which is slim overall and has a rechargeable battery. Amazon Link This keyboard is perfect for users who both work and games. Amazon currently sells for $119.99, down from its original price of $159.99, only once before it reached this price. G515 Lightspeed TKL is slim in size, 14.49 inches long and 5.91 inches wide,

How to Enable TPM 2.0 to Get Windows 11How to Enable TPM 2.0 to Get Windows 11Apr 21, 2025 am 11:17 AM

Many users with powerful desktops were initially blocked from upgrading to Windows 11 due to a simple BIOS setting being disabled by default: TPM 2.0. This guide explains how to enable it. Checking for TPM Compatibility Windows has a built-in tool t

How to Download a Website as an App on the DesktopHow to Download a Website as an App on the DesktopApr 21, 2025 am 10:37 AM

Quickly Access Your Favorite Websites: Two Methods for Adding Websites to Your Desktop Tired of hunting through bookmarks? Windows offers easy ways to add frequently visited websites directly to your desktop for instant access. This guide details tw

8 Ways to Open the Run Dialog Box on Windows 118 Ways to Open the Run Dialog Box on Windows 11Apr 20, 2025 am 06:01 AM

Windows 11's Run dialog box (Run) provides a convenient way to quickly access various system features and installed applications. The way to start this dialog is simple, just use keyboard shortcuts or select menu items. This article will describe several ways to start this utility. Use keyboard shortcuts to open the run dialog The quickest way to start a Run dialog on Windows 11 is to use keyboard shortcuts. This method opens the dialog box instantly. To do this, press the Windows R key on the keyboard. No matter where you are currently on your computer, Windows 11 will immediately open the Run dialog box. You can then enter the name of the utility you want to start.

Samsung's 32-inch Odyssey G7 IPS Gaming Monitor Is $270 Off TodaySamsung's 32-inch Odyssey G7 IPS Gaming Monitor Is $270 Off TodayApr 20, 2025 am 03:01 AM

Samsung Odyssey G7 (G70D) 32-inch Esports Monitor Special Offer! Original price is $800, current price is only $530, saving $270! This Odyssey G7 sports monitor has 4K resolution, IPS panel, 144Hz refresh rate, AMD FreeSync Premium support, and smart Tizen capabilities. Samsung's official website priced at $530 If you need a monitor that supports high refresh rate gaming, this Samsung 32-inch Odyssey G7 monitor is ideal for you. Currently on sale, priced at $530, $270 less than the original price, and comes with 4K resolution, IPS panel and smart software capabilities. 32-inch Odyss

6 Tasks You Should Do Regularly on Your Windows Computer6 Tasks You Should Do Regularly on Your Windows ComputerApr 19, 2025 am 03:01 AM

Maintaining a Windows computer requires regular upkeep to ensure smooth operation and prevent performance issues, security risks, and unnoticed hardware problems. Here's a routine maintenance checklist to keep your computer running smoothly: 1. Run

How to Right-Click With No MouseHow to Right-Click With No MouseApr 18, 2025 pm 12:03 PM

The mouse is a vital component to getting work done on your PC. But when you’re stuck with a faulty mouse, you can run into a few problems including the inability to right-click. But the good news is that there are definitely ways t

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools