+ Reply to Thread
Results 1 to 2 of 2

Help To Generate List of WorkSheet Names

  1. #1
    Registered User
    Join Date
    01-04-2005
    Posts
    4

    Help To Generate List of WorkSheet Names

    Could anyone help me?

    I have a workbook in which there are numerous sheets (ie. jan 01, jan02, etc...).
    It's constantly growing. My lst sheet is a summary sheet. The data on each sheet is formatted the same. I am pulling data off each sheet and generating a summary sheet.

    I would like to generate a list on my summary sheet of all my sheets excluding the last one.

    Can this be done in Excel?

  2. #2
    Forum Contributor
    Join Date
    11-16-2004
    Posts
    282
    The following macro generates a list in column E on the 1st sheet in the workbook of all sheets except 1st & last and creates a hyperlink to the respective sheet (change the cell reference E1 in BOLD to your own):

    Sub createListFromSheets()
    ' Declare variables
    Dim sheetCount, loopLimit, sheetIndex, sheetName, fileName
    ' Loop through the worksheets in the workbook & create list for each sheet except last
    sheetCount = ActiveWorkbook.Worksheets.Count
    loopLimit = sheetCount - 1
    sheetIndex = 1
    ActiveWorkbook.Worksheets(1).Activate
    ActiveSheet.Range("E1").Select
    Do Until sheetIndex = loopLimit
    sheetIndex = sheetIndex + 1
    sheetName = ActiveWorkbook.Worksheets(sheetIndex).Name
    ActiveCell.Value = sheetName
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", _
    SubAddress:=fileName & "'" & sheetName & "'!A1", TextToDisplay:=sheetName
    ActiveCell.Offset(1, 0).Select
    Loop
    End Sub

    Hope this helps,
    theDude

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1