Need Macro to Collect Multiple Worksheet Names

N

navel151

I need a macro to collect the names of every worksheet in a workbook such
that the names are in adjacent cells in one worksheet. The number of
worksheets can vary and ideally I don't want to collect the names of the last
2 sheets but I can always just delete them manually.

B3 = sheet1 name
B4 = sheet2 name
B5 = sheet 3 name and so on

Thx.
 
M

Max

Run this sub in a new sheet (it'll list all sheetnames),
then just delete whatever is not required

Sub ListSheetNames()
Dim wkSht As Worksheet
Range("B2").Select
For Each wkSht In Worksheets
Selection = wkSht.Name
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
Next wkSht
End Sub
 
N

navel151

TY :)

Max said:
Run this sub in a new sheet (it'll list all sheetnames),
then just delete whatever is not required

Sub ListSheetNames()
Dim wkSht As Worksheet
Range("B2").Select
For Each wkSht In Worksheets
Selection = wkSht.Name
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
Next wkSht
End Sub
 
G

Gord Dibben

Sub CreateListOfSheetsOnFirstSheet()
Dim WS As Worksheet
For i = 1 To Worksheets.Count - 2
With Worksheets(1)
Set WS = Worksheets(i)
.Cells(i, 2).Value = WS.Name
End With
Next i
End Sub


Gord Dibben MS Excel MVP
 

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

Top