Worksheet name list


Posted by Kurt on June 29, 2001 7:02 AM

Is there a way to get a list of the worksheet names in a workbook onto one worksheet?

I was just given a file with a large number of worksheets. When you go to Properties under the File menu it gives you a list of worksheets under the Contents tab. What I want is a way to get that list into a worksheet.

Thanks.

Kurt

Posted by faster on June 29, 2001 7:48 AM

This works pretty good. I wrote it for about the
same reason you need it. It will toggle a sheet
called SheetNames; that contains all of your
sheet names.


Sub ListSheetNames()

Dim NumSheets
NumSheets = Sheets.Count

Application.DisplayAlerts = False
Dim i
For i = 1 To NumSheets + 1
If ActiveSheet.Name = "SheetNames" Then
Sheets("SheetNames").Select
ActiveWindow.SelectedSheets.Delete
Exit Sub
End If
Next i
Application.DisplayAlerts = True

Sheets.Add
ActiveSheet.Name = "SheetNames"
Sheets("SheetNames").Move after:=Sheets(NumSheets + 1)
'MsgBox (NumSheets)



For i = 1 To NumSheets
Range("A" & i) = Sheets(i).Name
Next i

End Sub



Posted by faster on June 29, 2001 7:58 AM

Sorry I sent you the wrong code. You better use this instead.

Sub ListSheetNames()

Dim NumSheets
NumSheets = Sheets.Count

Application.DisplayAlerts = False
Dim i
For i = 1 To NumSheets
Sheets(i).Select
If ActiveSheet.Name = "SheetNames" Then
Sheets("SheetNames").Select
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
Exit Sub
End If
Next i

Sheets.Add
ActiveSheet.Name = "SheetNames"
Sheets("SheetNames").Move after:=Sheets(NumSheets + 1)

For i = 1 To NumSheets
Range("A" & i) = Sheets(i).Name
Next i

End Sub