List the worksheets in a workbook

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to list the worksheet names in a workbook using the Immediate window.
What should I type in this window to do this?
 
? Sheets.Item(2).name

Or you could just write the code to loop the names to the immediate window:

Sub SheetNames()
Dim intSheets As Integer
Dim i As Integer

intSheets = Sheets.Count

For i = 1 To intSheets
Debug.Print Sheets.Item(i).Name
Next

End Sub

Ken
 
The following compound statement will insert the names of all
worksheets in your active workbook in Column A of the active worksheet.
Note the use of colons (":") to separate statements. Ignore any line
breaks displaying in the newsgroup post.

Range("A1").Select:For x = 1 to
Application.ActiveWorkbook.Sheets.Count:
ActiveCell.Offset(x-1,0).Value=sheets(x).name:Next x

Just a side note: Right-clicking on the sheet navigation arrows on the
bottom left will display a list of all sheet names.

-Glenn Ray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top