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

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?
 
J

Jacob Skaria

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
 

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