How to Create a List of All Worksheet Names from a Workbook


Accessing and managing worksheet names is an important skill because Excel is a potent tool for data analysis and organisation. Regardless of your level of Excel proficiency, this tutorial will walk you through the procedure step-by-step. Have you ever struggled to remember the names of all the worksheets in a large Excel workbook with numerous worksheets? Maybe you needed to refer to a particular sheet but forgot its name, or you wanted to make a table of contents for quick access. We will examine a quick and effective technique to create a list of all worksheet names in an Excel file in this article.

By the end of this tutorial, you will understand how to automate the extraction and display of all worksheet names using built-in Excel functions and Visual Basic for Applications (VBA). Your productivity will increase and your Excel projects will become more organised if you know how to construct a list of all worksheet titles, regardless of how experienced an Excel user you are. So let's get started and master this crucial ability to unleash Excel's full potential!

Create a List of All Worksheet Names from a Workbook

Here, we will first create a VBA module and then run it to complete the task. So let us see a simple process to know how you can create a list of all worksheet names from a workbook in Excel.

Step 1

Consider any Excel workbook with multiple worksheets.

First, right-click on the sheet name and select View Code to open the VBA application.

Step 2

Then click on Insert and select Module, then copy the below code into the text box.

Insert > Module > Copy.

Example

Sub CreateIndex()
    Dim xAlerts As Boolean
    Dim I  As Long
    Dim xShtIndex As Worksheet
    Dim xSht As Variant
    xAlerts = Application.DisplayAlerts
    Application.DisplayAlerts = False
    On Error Resume Next
    Sheets("Index").Delete
    On Error GoTo 0
    Set xShtIndex = Sheets.Add(Sheets(1))
    xShtIndex.Name = "Index"
    I = 1
    Cells(1, 1).Value = "INDEX"
    For Each xSht In ThisWorkbook.Sheets
        If xSht.Name <> "Index" Then
            I = I + 1
            xShtIndex.Hyperlinks.Add Cells(I, 1), "", "'" & xSht.Name & "'!A1", , xSht.Name
        End If
    Next
    Application.DisplayAlerts = xAlerts
End Sub

Step 3

Then click F5 to complete the task. Then you can see that a list of all sheet names will be created.

Conclusion

In this tutorial, we have used a simple example to demonstrate how you can create a list of all worksheet names from a workbook in Excel to highlight a particular set of data.

Updated on: 12-Jul-2023

102 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements