Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Is it possible to select one OptionButton and deselect the other?

0

Hello,

Is it possible to select one OptionButton and deselect the other?

Because i can't make it work it keeps them all selected

in my frameControl

Private Sub Chk_Click()

Dim ctl         As MSForms.control
    For Each ctl In Chk.Parent.Controls

        If TypeName(ctl) = "OptionButton" Then
        With ctl

                If .Name = Chk.Name Then
                    If .Value = True Then
                    .Value = False
                    Else
                   .Value = True
                    End If              
                End If
        End With
        End If
Next ctl
End Sub

Thanks

Answer
Discuss

Discussion

Can't you just put your dynamically added optionbuttons into a frame and have this behaviour done automatically? 
don (rep: 1989) Oct 6, '20 at 5:19 am
Add to Discussion



Answer the Question

You must create an account to use the forum. Create an Account or Login