View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default udf for returning names of wrkshts in active workbook

List all Sheets in the Book:
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

List Sheets in the Book, 30 at a time, then shift over, list 30, repeat:
Sub ShowNames_Click()
Dim wkbkToCount As Workbook
Dim ws As Worksheet
Dim iRow As Integer, iCol As Integer
Set wkbkToCount = ActiveWorkbook
iRow = 2
iCol = 1
For Each ws In wkbkToCount.Worksheets
ActiveSheet.Rows(iRow).Cells(iCol).Value = ws.Name
iRow = iRow + 1
If iRow 30 Then
iRow = 2
iCol = iCol + 1
End If
Next
Range("A1").Select
End Sub

Regards,
Ryan---

--
RyGuy


"Bassman62" wrote:

Using xl-2007;
Is there a UDF one could use to return all of the names of the worksheets in
the active workbook?
Thanks.