+ Reply to Thread
Results 1 to 3 of 3

Combo box and option buttons

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

    Combo box and option buttons

    I have an excel sheet with 5 option buttons (toolbox option buttons) embedded in the sheet. I also have a combobox embedded on the same sheet. Off to the side, I have a list of values that I would like to fill the combobox with based on which option button is selected. I'm not too familiar with using the case select command in VBA. Right now, I have the following code for the combobox:

    Private Sub ComboBox4_Change()
    If OptionButton1.Value = True Then
    Sheet1.ComboBox4.ListFillRange = "T5:T278"

    Else

    If OptionButton2.Value = True Then
    Sheet1.ComboBox4.ListFillRange = "T279:T552"

    Else

    If OptionButton3.Value = True Then
    Sheet1.ComboBox4.ListFillRange = "T1150:T1639"

    Else

    If OptionButton4.Value = True Then
    Sheet1.ComboBox4.ListFillRange = "T1640:T1676"

    Else

    If OptionButton5.Value = True Then
    Sheet1.ComboBox4.ListFillRange = "T553:T1149"

    End If
    End If
    End If
    End If
    End If


    End Sub

    This works fine but only if I select a value from the combobox twice, meaning that if option button 2 is checked, the values for option button 3 might be in the combobox unless I click on a value on the list and then the values for option 2 are now in the combobox. It sounds a lot more complicated than it is but I don't know how to fix it!

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    you don't want the change fill range to be connected to the combo box change routine. It should be hooked to each option button's Click routine. Here is a different form of your routine. The click event for each of the option buttons calls the reset routine.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-23-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Combo box and option buttons

    Apologies I responded accidentally.
    Last edited by acj06; 11-15-2011 at 05:44 AM. Reason: Accidentally replied to a thread instead of starting one.

+ 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