How to Create Dynamic Table of Contents in Excel (3 Easy Methods)

A dynamic table of contents in Excel allows users to create an interactive and automated index for their workbooks. By linking sheet names and hyperlinks, it enables easy navigation within large Excel files, providing a convenient way to organize and access data, improving efficiency and user experience.

In this article, we will describe how to create a dynamic table of contents in Excel. Here is an overview:

Overview of a dynamic table of contents in Excel


Download Practice Workbook


How to Create Dynamic Table of Contents in Excel: 3 Easy Methods

Suppose we have a dataset of a shop’s sales, with each month’s sales in its own worksheet. Let’s create a dynamic table of contents for these multiple worksheets.

Sample dataset of a dynamic table of contents in Excel


Method 1 – Combining the GET.WORKBOOK, HYPERLINK, INDEX, REPLACE, FIND, T, and NOW Functions

The main advantages of this approach are automatic updates and clickable links for easy access.

Steps:

  • Create a new worksheet in which to place the table of contents.

We’ll define a name for ease of use within our formulas.

  • Click Name Manager from the Formulas tab.

Creating Name Manager from the Formulas tab

  • Select New in the Name Manager window.

Clicking New option to create a new name manager

  • In the Name section, put your own choice of name.
  • In the Refers to section, enter the following formula:

=REPLACE(GET.WORKBOOK(1),1,FIND("]",GET.WORKBOOK(1)),"")

Applying formula to Refer to section and naming it

Formula Breakdown:

  • GET.WORKBOOK(1)

Retrieves the name of the currently open workbook. Argument 1 specifies the workbook name type.

  • FIND(“]”, GET.WORKBOOK(1))

Locates the position of the closing square bracket (“]”) within the workbook name obtained from GET.WORKBOOK(1).

  • REPLACE(GET.WORKBOOK(1), 1, FIND(“]”, GET.WORKBOOK(1)), “”)

Replaces the portion of the workbook name string obtained from GET.WORKBOOK(1) starting from the first character and extending to the position of the closing bracket (found using FIND). The replacement is an empty string (“”).

  • Close the Name Manager box.
  • In cell B5, enter the following formula:

=IFERROR(HYPERLINK("#'"&INDEX(Dynamic_Table_of_Contents,ROW(A1))&"'!A1",INDEX(Dynamic_Table_of_Contents,ROW(A1))),"")

Formula to create a dynamic table of contents in the worksheet

Formula Breakdown:

  • ROW(A1):

Returns the row number of Cell A1.

  • INDEX(Dynamic_Table_of_Contents,ROW(A1))

Retrieves the value from the Dynamic_Table_of_Contents array based on the row number of cell A1.

  • INDEX(Dynamic_Table_of_Contents, ROW(A1))&”‘!A1″ :

Appends the retrieved value from the previous step with the text “‘!A1”. This is used to construct a reference to cell (A1) in a specific sheet.

  • “#'”&INDEX(Dynamic_Table_of_Contents,ROW(A1))&”‘!A1” :

Concatenates the “#” symbol, then retrieves the value from the first step (sheet name), and the “‘!A1” reference to form a complete hyperlink destination.

  • HYPERLINK(“#'”&INDEX(Dynamic_Table_of_Contents,ROW(A1))&”‘!A1″,INDEX(Dynamic_Table_of_Contents,ROW(A1))),””) :

Creates a clickable hyperlink. The first argument is the constructed hyperlink destination from the previous step, and the second argument is the display text for the hyperlink.

  • IFERROR(HYPERLINK(“#'”&INDEX(Dynamic_Table_of_Contents,ROW(A1))&”‘!A1”,INDEX(Dynamic_Table_of_Contents,ROW(A1))), “”) :

Finally, the IFERROR function is used to handle any errors that may occur. It attempts to create a hyperlink using the HYPERLINK function. If an error occurs, such as if the sheet name is not found in the “Dynamic_Table_of_Contents” array, it returns an empty string (“”).

  • Press ENTER.

The dynamic table of contents is created.

Final output by creating dynamic table of contents

  • To check it works properly, simply click any of the hyperlinks on the sheet.

Clicking the linked table of contents to check whether it’s working or not

It should take you to the relevant worksheet.

Visiting the linked worksheet by using the table of content sheet

You can also change the worksheet name and it will automatically update in the table of contents wall. For example, here, we changed the worksheet name from “February” to “Feb”.

Changing worksheet name to check whether the dynamic table updating automatically or not

In the table of contents sheet, the worksheet name has changed, confirming the successful creation of a dynamic table of contents.

Final result with changed worksheet name in the table of contents sheet


Method 2 – Using a Formula to Create a Semi-Dynamic Table of Contents

We can also create a semi-dynamic table of contents by combining the CELL, TEXTAFTER, VSTACK, and HYPERLINK functions. This approach simplifies maintenance, improves worksheet organization, and automatically updates as sheets are added, deleted, or rearranged.

Steps:

First, we’ll select all the sheets to put the sheet name in a specific location within all the worksheets.

  • Holding down the CTRL key, click the left arrow on the left of the Sheet bar.

Holding CTRL key to select all the sheets from the workbook

  • Holding down the SHIFT key, click the first worksheet.

Pressing SHIFT key to choose all the worksheets

Thus all the sheets will be selected.

Selected all worksheets using the keyboard shortcut keys

  • Select cell C15, enter the following formula, and press Enter:

=TEXTAFTER(CELL("filename",C15),"]")

Formula to include the sheet name in all the worksheets

We have the sheet names of all the worksheets in cell C15.

Result with including sheet names in all the worksheets

Now we apply the VSTACK function to arrange all the sheet names in one worksheet.

  • In cell C5, enter the following formula:

=VSTACK(January:Semi_Dynamic!C15)

Applying VSTACK formula to insert table of contents

  • Pressing ENTER will provide us all the sheet names, like in the image below.

Created table of contents which includes all the sheet names

We are ready to link all the sheets with the HYPERLINK function.

  • In cell B5, enter the following formula:

=HYPERLINK("#'"&C5&"'!A1",C5)

Formula to link table of content cells

We have successfully created a (semi-)dynamic table of contents in Excel.

Final output with a dynamic table of contents linking all the cells

  • To check whether it’s working properly, simply click any linked content in the table.

Clicking a linked cell to check if it’s working properly or not

Immediately you will jump to the corresponding worksheet.

Visiting the clicked worksheet from the table of contents sheet

For added convenience, we can add the main table of contents sheet to all the worksheets, so that we can jump back to the main content sheet with a single click from any sheet.

  • Select cell C17.
  • Click Insert Link from the Insert tab.

Inserting a linked cell for the main table of content sheet

  • Choose the table of contents sheet where all the sheet names are located.
  • Put your own choice of name in the Text to display section.
  • Click OK.

Linking a worksheet and naming it

In this whis way, we have added the link to the table of contents sheet.

  • Check it by clicking the newly created link.

Result with linked table of the content sheet in one single sheet

Within a blink of an eye, we have moved to the table of contents sheet.

Visiting the linked worksheet by clicking the newly created linked cell

  • To copy this linked cell to all the worksheets, simply press CTRL+C to copy.

Copying the linked table of contents sheet for all the worksheets

  • Just like in the previous steps, select all sheets from the workbook, choose cells B17:C17, and press CTRL+V to paste.
  • Make sure the chosen cells are blank for all the sheets, otherwise it won’t work.

Selecting all the sheets and pasting the linked cell

Our linked cells are copied to each worksheet.

Result with creating main table of content cell for all the worksheets


Method 3 – Using a VBA Macro to Insert a Dynamic Table of Contents

The main purpose of inserting a dynamic table of contents is to provide a convenient way to navigate through a document’s structure and quickly access specific sections. By applying VBA code, we can automate the table of contents. After applying the code, the table will automatically update whenever changes are made to the workbook.

Steps:

  • Follow this link to open the VBA window and insert a module.
  • Inside the module, place the below code and click the Save icon:
Sub Dynamic_table_of_contents()
xAlerts = Application.DisplayAlerts
Application.DisplayAlerts = False
On Error Resume Next
Set Sheet_TOC = Sheets("VBA")
On Error GoTo 0
If Sheet_TOC Is Nothing Then
Exit Sub
End If
I = 4
For Each WS In ThisWorkbook.Sheets
If WS.Name <> "VBA" Then
I = I + 1
Sheet_TOC.Hyperlinks.Add Sheet_TOC.Cells(I, 2), "", "'" & WS.Name & "'!A1", , WS.Name
End If
Next
Application.DisplayAlerts = xAlerts
End Sub

VBA code to create a dynamic table of contents

  • Insert the following code with a private sub inside the sheet.
  • Don’t forget to change to Worksheet and Activate to run your VBA code properly.
Private Sub Worksheet_Activate()
Dynamic_table_of_contents
End Sub

VBA code with private sub inside the chosen sheet

After running the code, our automated table of contents is successfully created

Final output with creating a dynamic table of contents using VBA

  • To check that it’s working properly, change the name of the worksheet from January to Jan.

Changing the worksheet name to check the dynamic table of contents sheet automatically updating or not

In the main table of contents, the name has changed automatically.

Updated dynamic table of content with changed sheet name

  • Add another worksheet by clicking the plus (+) icon on the Sheet bar like in the image below.

Adding a new worksheet inside the workbook

As the new sheet is created, the table of contents updates to include the new sheet in the list automatically.

Automatic adding of new worksheet name inside the dynamic table of content sheet


Things to Remember

  • When creating multiple sheets, ensure that the sheet names used in the table of contents match the actual sheet names in your workbook. Any discrepancies can lead to broken links and errors.
  • If you plan to dynamically update the table of contents, as you add or remove sheets be mindful of maintaining a consistent sheet order and structure.

Frequently Asked Questions

Can I automatically update the Table of Contents when I add or remove sheets in my workbook?

Yes, you can set up the table of contents to automatically update by using dynamic formulas, such as INDEX and INDIRECT.

Is it possible to customize the appearance and formatting of the table of contents?

Yes, by applying formatting styles, changing font sizes, adding colors, and modifying cell borders.

Can I create a hierarchical or nested table of contents with multiple levels?

Yes, by using indentation or multiple columns.


 

Get FREE Advanced Excel Exercises with Solutions!
Wasim Akram
Wasim Akram

Wasim Akram holds a BSc degree in Industrial and Production Engineering from Ahsanullah University of Science and Technology. Over the past 2 years, he has been actively contributing to the ExcelDemy project, where he has authored more than 150 articles. Now, he is working as an Excel VBA and Content Developer. He likes learning new things about Microsoft Office, especially Excel VBA, Power Query, Data Analysis, and Excel Statistics. He is also very interested in machine learning and... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo