ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   List the worksheets in a workbook (https://www.excelbanter.com/excel-programming/319688-list-worksheets-workbook.html)

Kirk P.

List the worksheets in a workbook
 
I want to list the worksheet names in a workbook using the Immediate window.
What should I type in this window to do this?

vb_Sagacious

List the worksheets in a workbook
 
? 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


"Kirk P." wrote:

I want to list the worksheet names in a workbook using the Immediate window.
What should I type in this window to do this?


Glenn

List the worksheets in a workbook
 
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



All times are GMT +1. The time now is 04:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com