+ Reply to Thread
Results 1 to 3 of 3

Combo Box Macro?

Hybrid View

  1. #1
    Registered User
    Join Date
    05-15-2007
    Posts
    16

    Combo Box Macro?

    Hello. I need a macro to accomplish 2 things with a combo box on a user form.

    Populate the items of the combo box with the sheet titles of an excel file (for the purpose, I have a file with 53 sheets).

    Then, once a selection is made in the combo box, open the selected sheet as the active sheet.

    How do I code this? If someone would be kind to a new user and give me an example code, I would be very thankful.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    in a normal code module
    Sub fillComboBox()
        Dim xsheet As Worksheet
        With UserForm1.ComboBox1
            For Each xsheet In ThisWorkbook.Sheets
                .AddItem xsheet.Name
            Next xsheet
        End With
        UserForm1.Show
        End Sub
    
    Sub reactToComboBox()
        ThisWorkbook.Sheets(UserForm1.ComboBox1.Value).Activate
        End Sub
    In the Userform code module
    Private Sub ComboBox1_Change()
        Call reactToComboBox
        End Sub

  3. #3
    Registered User
    Join Date
    05-15-2007
    Posts
    16
    Thank you very much!

+ 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