![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: May 2002
Posts: 60
|
I have a workbook that has lots of sheets in it. I was wondering if there is a way print just a list of the the individual sheetnames.
|
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Posts: 363
|
Try the following VBA macro:
Sub ListSheetNames() Dim wks As Worksheet Dim x As Integer Worksheets.Add before:=Sheets(1) x = 0 For Each wks In Worksheets x = x + 1 Cells(x, 1) = wks.Name Next wks End Sub
__________________
It's never too late to learn something new. Ricky |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: May 2002
Posts: 60
|
A friend found this soon after I posted. It is modified from some Excel help macro to print and delete. Enjoy!
Attribute VB_Name = "Get_PrintSheetNames" Sub Get_PrintSheetNames() Set NewSheet = Sheets.Add(Type:=xlWorksheet) NewSheet.Name = "NameList" For i = 1 To Sheets.Count If Sheets(i).Name <> "NameList" Then j = j + 1 NewSheet.Cells(j, 1).Value = Sheets(i).Name End If Next i 'This line prints out the sheet with the list of names. ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True 'These lines copy the selection to the clipboard. 'Cells.Select 'Selection.Copy 'This line deletes the NameList sheet. ActiveWindow.SelectedSheets.Delete End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|