+ Reply to Thread
Results 1 to 7 of 7

display sheet choices in combo box

  1. #1
    Wazooli
    Guest

    display sheet choices in combo box

    Is it possible to have a combo box give the user a choice of sheets within a
    workbook, and to then open the selected sheet?

    Wazooli

  2. #2
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    Yes. In the examples below, I have a ComboBox on Sheet1. Every time that Sheet1 is selected it refills the ComboBos with the names of all worksheets in the workbook. When a selection is made from the ComboBox, that worksheet is selected.


    Private Sub Worksheet_Activate()
    Dim ws As Worksheet

    Sheet1.ComboBox1.Clear
    For Each ws In ThisWorkbook.Worksheets
    Sheet1.ComboBox1.AddItem ws.Name
    Next ws
    End Sub


    Private Sub ComboBox1_Change()
    myWS = Sheet1.ComboBox1.Value
    If myWS <> "" Then Sheets(myWS).Select
    Sheet1.ComboBox1.Value = ""
    End Sub

  3. #3
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    ooops, I forgot to say ...

    All of this code needs to go on the Code Window for the Sheet that contains the ComboBox. In this case, Sheet1.

    - Pete

  4. #4
    Vasant Nanavati
    Guest

    Re: display sheet choices in combo box

    Yes, but why bother? You can do the same thing by right-clicking on the
    VCR-type buttons at the bottom left of the workbook window.

    --

    Vasant



    "Wazooli" <[email protected]> wrote in message
    news:[email protected]...
    > Is it possible to have a combo box give the user a choice of sheets within

    a
    > workbook, and to then open the selected sheet?
    >
    > Wazooli




  5. #5
    Tom Ogilvy
    Guest

    Re: display sheet choices in combo box

    Sub Drpdwn_Click()
    Dim sSheet as String, sName as String
    sname = Application.Caller
    With Activesheet.DropDowns(sName)
    sSheet = .List(.ListIndex)
    End With
    Worksheets(sSheet).Activate
    End Sub

    To load you forms Dropdown/Combobox

    sub LoadBox()
    Dim sh as Worksheet
    with Activesheet.DropDowns("Drop Down 1")
    .RemoveAllItems
    for each sh in ThisWorkbook.Worksheets
    .AddItem sh.Name
    Next
    End With
    End Sub

    --
    Regards,
    Tom Ogilvy


    "Wazooli" <[email protected]> wrote in message
    news:[email protected]...
    > Is it possible to have a combo box give the user a choice of sheets within

    a
    > workbook, and to then open the selected sheet?
    >
    > Wazooli




  6. #6
    Wazooli
    Guest

    Re: display sheet choices in combo box

    Thanks Tom. I'm glad you can appreciate what I am trying to accomplish. I
    will try this the next chance I get.

    Wazooli

    "Tom Ogilvy" wrote:

    > Sub Drpdwn_Click()
    > Dim sSheet as String, sName as String
    > sname = Application.Caller
    > With Activesheet.DropDowns(sName)
    > sSheet = .List(.ListIndex)
    > End With
    > Worksheets(sSheet).Activate
    > End Sub
    >
    > To load you forms Dropdown/Combobox
    >
    > sub LoadBox()
    > Dim sh as Worksheet
    > with Activesheet.DropDowns("Drop Down 1")
    > .RemoveAllItems
    > for each sh in ThisWorkbook.Worksheets
    > .AddItem sh.Name
    > Next
    > End With
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Wazooli" <[email protected]> wrote in message
    > news:[email protected]...
    > > Is it possible to have a combo box give the user a choice of sheets within

    > a
    > > workbook, and to then open the selected sheet?
    > >
    > > Wazooli

    >
    >
    >


  7. #7
    Tom Ogilvy
    Guest

    Re: display sheet choices in combo box

    Again, that is a combobox from the Forms toolbar. Not from the Control
    Toolbox Toolbar. If you want to use the latter, post back.

    --
    Regards,
    Tom Ogilvy

    "Wazooli" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks Tom. I'm glad you can appreciate what I am trying to accomplish.

    I
    > will try this the next chance I get.
    >
    > Wazooli
    >
    > "Tom Ogilvy" wrote:
    >
    > > Sub Drpdwn_Click()
    > > Dim sSheet as String, sName as String
    > > sname = Application.Caller
    > > With Activesheet.DropDowns(sName)
    > > sSheet = .List(.ListIndex)
    > > End With
    > > Worksheets(sSheet).Activate
    > > End Sub
    > >
    > > To load you forms Dropdown/Combobox
    > >
    > > sub LoadBox()
    > > Dim sh as Worksheet
    > > with Activesheet.DropDowns("Drop Down 1")
    > > .RemoveAllItems
    > > for each sh in ThisWorkbook.Worksheets
    > > .AddItem sh.Name
    > > Next
    > > End With
    > > End Sub
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > > "Wazooli" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Is it possible to have a combo box give the user a choice of sheets

    within
    > > a
    > > > workbook, and to then open the selected sheet?
    > > >
    > > > Wazooli

    > >
    > >
    > >




+ 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