ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can you get a list of sheetnames? (https://www.excelbanter.com/excel-programming/389349-how-can-you-get-list-sheetnames.html)

Jack

How can you get a list of sheetnames?
 
Hello,

I am trying to get a list of sheetnames or at lesat the first sheet name of
a XSL file.

Thanks in advance for any help,

Jack


Barb Reinhardt

How can you get a list of sheetnames?
 
This will put the worksheet names in the IMMEDIATE window

Sub ListWorksheets()
Dim aWS As Worksheet

For Each aWS In ActiveWorkbook.Worksheets
Debug.Print aWS.Name, aWS.CodeName
Next aWS

End Sub

"Jack" wrote:

Hello,

I am trying to get a list of sheetnames or at lesat the first sheet name of
a XSL file.

Thanks in advance for any help,

Jack


JMay

How can you get a list of sheetnames?
 
In a standard module:

Sub ListOutSheetNames()
Application.ScreenUpdating = False
Dim Nsheet As Worksheet
Set Nsheet = Sheets.Add
Dim WS As Worksheet
Dim r As Integer
r = 1
For Each WS In Worksheets
If WS.Name < Nsheet.Name Then
Nsheet.Range("A" & r) = WS.Name
r = r + 1
End If
Next WS
Application.DisplayAlerts = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub




"Jack" wrote in message
:

Hello,

I am trying to get a list of sheetnames or at lesat the first sheet name of
a XSL file.

Thanks in advance for any help,

Jack




All times are GMT +1. The time now is 03:49 PM.

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