How to create and list all worksheet names from a workbook?
We may need to get a list of worksheet names in a workbook. For example, we might want to create an index of worksheet names in workbook. To make such a list is not simple, this tutorial is giving instructions on how to list worksheet names in Excel.
The following two VBA codes can help you list all of the worksheet names in a new worksheet or the active worksheet. Please do as this:
1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA: List all worksheet names in a new worksheet:
Sub ListWorkSheetNamesNewWs() 'Updateby Extendoffice Dim xWs As Worksheet On Error Resume Next Application.DisplayAlerts = False xTitleId = "KutoolsforExcel" Application.Sheets(xTitleId).Delete Application.Sheets.Add Application.Sheets(1) Set xWs = Application.ActiveSheet xWs.Name = xTitleId For i = 2 To Application.Sheets.Count xWs.Range("A" & (i - 1)) = Application.Sheets(i).Name Next Application.DisplayAlerts = True End Sub
2. Then click button to run the code, and all of the worksheet names in active workbook have been listed into a new worksheet called KutoolsforExcel, see screenshot:
The above code only support to create a list of all worksheet names in the workbook, but if you want to add links to the worksheet names, how could you do? The following method may help you.
With the Create List of Sheet Names utility of the third party add-in Kutools for Excel, you are able to create a list of worksheet names in one click, and link to each worksheet with hyperlink.
|Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.|
After installing Kutools for Excel, please do as follows:
1. Click Enterprise > Worksheet > Create List of Sheet Names, see screenshot:
2. In the Create List of Sheet Names dialog box, please specify the following settings:
3. After finishing the settings, then click OK. All of the worksheet names have been listed with links in a new worksheet of the current workbook. See screenshot:
|worksheet names with hyperlinks||worksheet names with macro buttons|
You are guest
or post as a guest, but your post won't be published automatically.
- To post as a guest, your comment is unpublished.· 2 years agoThanks so much, this worked great.
- To post as a guest, your comment is unpublished.· 2 years agoWorks great!! Thank you!!!!
- To post as a guest, your comment is unpublished.· 2 years agosooooo helpful, works as expected!!!!! Thanks
- To post as a guest, your comment is unpublished.· 2 years agoTHANK YOU SO MUCH! I freaking love your website. In a matter of minutes I've had a ton of time saved with two sections of this site including this one. Love it!
- To post as a guest, your comment is unpublished.· 2 years agoHi
I would like to know how to list the tab color next to the tab name in this macro?
E.g. in the KutoolsforExcel sheet list:
Column A Column B
- To post as a guest, your comment is unpublished.· 2 years agoVBA code works nice to save times ever , Thanks tooooooooooooooooooooooooooooooo much
- To post as a guest, your comment is unpublished.· 5 years agoit's great worked like charm
- To post as a guest, your comment is unpublished.· 5 years agothe best it worked like charm
- To post as a guest, your comment is unpublished.· 6 years agoThe 'Range' step in your ListWorkSheetNames macro generates runtime error 1004: method range of object global failed. I have it saved in a PERSONAL.XLSB module, running from a macro-enabled spreadsheet in Office10. What am I missing?
For i = 1 To Sheets.Count
Range(”A” & i) = Sheets(i).Name
- To post as a guest, your comment is unpublished.· 6 years agoHow to list the Sheetname of a sub WB and list them in the Main WB?
- To post as a guest, your comment is unpublished.· 6 years agoGreat - but how do I do this in Visio ie for an index of worksheets in visio?