Quickie macro to return worksheet names into a list
Eliminate Pivot Table Annoyances
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Quickie macro to return worksheet names into a list

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    245
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    could someone please offer up a quick macro that returns sheet names (i.e., tab names) into a pre-defined column (let's say column B, rows 100 to 120 or so). 1 wrinkle, please return them in worksheet order (left to right). thanks.


    mach3

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    England, UK.
    Posts
    526
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Try this

    Sub tabnames()


    numberOfSheets = Worksheets.Count

    For i = 1 To numberOfSheets Step 1
    Cells(99+ i, 1)= Worksheets(i).Name
    Next i

    End Sub

    Hope this helps,

    RET79

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Location
    England, UK.
    Posts
    526
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    OR even more slick, use offset:


    Sub tabnames()

    numberOfSheets = Worksheets.Count

    For i = 1 To numberOfSheets Step 1
    Cells(100, 1).Offset(i - 1, 0) = Worksheets(i).Name
    Next i

    End Sub

  4. #4
    MrExcel MVP
    Colo's Avatar
    Join Date
    Mar 2002
    Location
    Kobe, Japan
    Posts
    1,456
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Default

      
    Please also try this code.

    Dim sh As Worksheet, i As Integer
    With Range("B100")
    Range(.Resize, .End(xlDown)).ClearContents 'Clear former data
    For Each sh In Worksheets 'Loop
    .Offset(i).Value = sh.Name
    i = i + 1
    Next
    End With
    End Sub

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com