Wednesday, January 18, 2012

How to list all sheets in Excel

Insert a new sheet and have that sheet active when you run the macro.

Right click on the sheet and click on 'view code'
Paste the below code and click on 'run'

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

'via Blog this'

No comments:

Post a Comment