0% found this document useful (0 votes)
17 views2 pages

List The Names of Worksheets

This document provides instructions for creating a macro button that lists the names of all worksheets in a workbook. The button adds a new worksheet, names it "SheetList", moves it to the end, and then loops through each worksheet, writing its name to cell A1, A2, etc. of the new SheetList worksheet. This allows users to easily see and access all worksheet names from a single list.

Uploaded by

VladimirGobeljic
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

List The Names of Worksheets

This document provides instructions for creating a macro button that lists the names of all worksheets in a workbook. The button adds a new worksheet, names it "SheetList", moves it to the end, and then loops through each worksheet, writing its name to cell A1, A2, etc. of the new SheetList worksheet. This allows users to easily see and access all worksheet names from a single list.

Uploaded by

VladimirGobeljic
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

LIST THE NAMES OF WORKSHEETS

In some instances, it is useful to be able to determine and list the names of the worksheets in your Excel workbooks. For example, you might want to create an index to catalog the worksheets in your workbook. You could then store the results in a separate worksheet. That way, you can quickly find the location of a particular worksheet. Try it: 1. Start Excel. A new, blank workbook appears. 2. Add a command button to the worksheet:

Select Sheet1. On the View menu, point to Toolbars, and then click Control Toolbox. Click the Command Button button. Click somewhere on the worksheet to insert the command button, and then click and drag the borders of the command button to size it.

3. Now, add Visual Basic code to the command button:

Right-click the command button, and then click View Code on the shortcut menu.

In the Microsoft Visual Basic Editor, enter the following code between the Private Sub CommandButton1 statement and the End Substatement:

Set NewSheet = Sheets.Add(Type:=xlWorksheet) For i = 1 To Sheets.Count NewSheet.Cells(i, 1).Value = Sheets(i).Name Next i

4. On the File menu, click Close and Return to Microsoft Excel. 5. On the Control Toolbox, click Exit Design Mode to quit design mode and enable the
command button. 6. Click the command button on Sheet1. A new worksheet is created, listing the names of all the worksheets in the workbook.

Sub ListWorkSheetNames() Dim Sheetnames Sheetnames = Sheets.Count

Sheets.Add ActiveSheet.Name = SheetList Sheets(SheetList).Move after:=Sheets(Sheetnames + 1) For i = 1 To Sheetnames Range(A & i) = Sheets(i).Name Next i End Sub

You might also like