How can you get a list of sheetnames?

  • Thread starter Thread starter Jack
  • Start date Start date
J

Jack

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
 
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
 
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
 

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