How to assign parent-child relationship to 2 optionbutton

miaski

New Member
Joined
Apr 16, 2018
Messages
2
I want to filter combobox1 to display 1 item from my list, but it does not work. I tried to put condition on worksheet, but still not working.



Code:
Public Sub Worksheet_Initialize()


    With ComboBox1


        If OptionButton2.Enabled = True Then
            .Clear
            .AddItem "All"
        End If
        
        If OptionButton3.Enabled = True Then
                .Clear
                .AddItem "One"
                .AddItem "Two"
                .AddItem "Three"
                .AddItem "Four"
        End If


    End With


    With ComboBox2
        .Clear
        .AddItem "Item 1"
        .AddItem "Item 2"
        .AddItem "Item 3"
        .AddItem "Item 4"
    End With


End Sub


Private Sub OptionButton1_Click()


    If OptionButton1.Enabled = True Then
        ComboBox1.Enabled = False
        OptionButton2.Enabled = True
        OptionButton3.Enabled = True
        
    Else
         ComboBox2.Enabled = False
    End If
    
End Sub


Private Sub OptionButton2_Click()


    If OptionButton2.Enabled = True Then
        ComboBox1.Enabled = True
    End If
    
End Sub


Private Sub OptionButton3_Click()
    
    If OptionButton2.Enabled = True Then
        ComboBox1.Enabled = True
    End If
    
End Sub


Private Sub OptionButton4_Click()
     
    If OptionButton4.Enabled = True Then
        ComboBox2.Enabled = True
        ComboBox1.Enabled = False
        OptionButton2.Enabled = False
        OptionButton3.Enabled = False
    End If
    
End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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