How can I print the names of all the sheets in a list?

  • Thread starter Thread starter SUN
  • Start date Start date
S

SUN

I have an exceldokument with 30 sheets and would like to print the names of
the sheets in a list. Someone who knows how that works?
 
You can try out the below macro. If you are new to macros..

--Set the Security level to low/medium in (Tools|Macro|Security).
--From workbook launch VBE using short-key Alt+F11.
--From menu 'Insert' a module and paste the below code.
--Get back to Workbook.
--Run macro from Tools|Macro|Run <selected macro()>


Sub GetSheetNames()
Dim sh As Worksheet, lngRow As Long
For Each sh In ActiveWorkbook.Worksheets
lngRow = lngRow + 1
Range("A" & lngRow) = sh.Name
Next
End Sub
 
Back
Top