List all sheets present in Workbook

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Looking for some code that will return the names of all worksheets present
in the workbook. The number of sheets and their names change...

Help?!
 
Sub allsheet()
Dim w As Worksheet
For Each w In ActiveWorkbook.Worksheets
MsgBox (w.Name)
Next
End Sub
 
Sorry.... Looking for it to list them in a column within Sheet 1, starting
in A1
 
Jeff

Sub ListSheets()
'list of sheet names starting at A1
Dim rng As Range
Dim i As Integer
Set rng = Sheets("Sheet1").Range("A1")
For Each Sheet In ActiveWorkbook.Sheets
rng.Offset(i, 0).Value = Sheet.Name
i = i + 1
Next Sheet
End Sub


Gord Dibben MS Excel MVP
 
No problem:


Sub allsheet()
Dim w As Worksheet
i = 1
For Each w In ActiveWorkbook.Worksheets
Sheets("Sheet1").Cells(i, "A").Value = w.Name
i = i + 1
Next
End Sub
 
that works... thanks!

Gary''s Student said:
No problem:


Sub allsheet()
Dim w As Worksheet
i = 1
For Each w In ActiveWorkbook.Worksheets
Sheets("Sheet1").Cells(i, "A").Value = w.Name
i = i + 1
Next
End Sub
 
Perfect.... thank you

Gord Dibben said:
Jeff

Sub ListSheets()
'list of sheet names starting at A1
Dim rng As Range
Dim i As Integer
Set rng = Sheets("Sheet1").Range("A1")
For Each Sheet In ActiveWorkbook.Sheets
rng.Offset(i, 0).Value = Sheet.Name
i = i + 1
Next Sheet
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

Back
Top