Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Aug 2001
    Thanked 0 Times in 0 Posts

    List Box... (2000)

    Hi All, I will be dealing with a workbook that contains many sheets. I want to, on a userform, show a List Box consisting of the names of all the sheets in the workbook. From there, I wish to select an item from that List Box and after pushing a button, prepare a special report on that selected sheet.

    More generally, how do I use the names of the sheets in a workbook as a data source for a list box in a userform? Would I have to put the sheet names into a worksheet first and use those cells as a data source?

  2. #2
    3 Star Lounger
    Join Date
    Mar 2001
    Silicon Valley, California, USA
    Thanked 0 Times in 0 Posts

    Re: List Box... (2000)

    Try this (that is, be sure to put this code into the UserForm_Activate event code block):

    <pre>Private Sub UserForm_Activate()

    Dim Sh

    For Each Sh In ActiveWorkbook.Sheets
    Me.ListBox1.AddItem Sh.Name
    Next Sh

    End Sub

    This will also put the names of chart sheets into the list box as well. If you want only worksheets, change Sheets to Worksheets in the For Each line.

Posting Permissions

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