Combobox Rowsource Dependent On Option Button Selection (Form Controls In Sheet)

glerwell

Well-known Member
Joined
Jun 25, 2006
Messages
1,082
Hi

I'm trying to write a code that will set the rowsource for 3 comboboxes that is dependent on which optionbox is selected. I have 2 optionboxes.

These are all form controls and are in my worksheet.

Here is the code I am trying:

Code:
Sub OptionButton1_Click()
    Call Options
End Sub
 
Sub OptionButton2_Click()
    Call Options
End Sub
Sub Options()

    Select Case True
    
        Case OptionButton1
            Sheets("SELECTIONS").Shapes("combobox1").RowSource = "todays_races"
            Sheets("SELECTIONS").Shapes("combobox2").RowSource = "todays_runners"
            Sheets("SELECTIONS").Shapes("combobox3").RowSource = "systems"
            
        Case OptionButton2
            Sheets("SELECTIONS").Shapes("combobox1").RowSource = "tomorrows_races"
            Sheets("SELECTIONS").Shapes("combobox2").RowSource = "tomorrows_runners"
            Sheets("SELECTIONS").Shapes("combobox3").RowSource = "systems"
            
        Case Else
            Sheets("SELECTIONS").Shapes("combobox1").RowSource = "todays_races"
            Sheets("SELECTIONS").Shapes("combobox2").RowSource = "todays_runners"
            Sheets("SELECTIONS").Shapes("combobox3").RowSource = "systems"
    End Select

End Sub

The two optionsbuttons have a macro assigned to them OptionButton1_Click for optionbutton1 and OptionButton2_Click for optionbutton 2.

I was hoping that the code called options would do the rest.

The code I am using was found on internet but I not entirely sure that it is to used in the way that I intend it to.

Anyway when I click on an optionbutton I am getting this message:

Runtime error 438: Object dosen't support this property or method.


What are I doing wrong or are I even on the right track with my code?

Cheers
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,224,506
Messages
6,179,158
Members
452,892
Latest member
yadavagiri

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top