GroupName property example

The following example uses the GroupName property to create two groups of OptionButton controls on the same form.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains five OptionButton controls named OptionButton1 through OptionButton5.

Private Sub UserForm_Initialize() 
 OptionButton1.GroupName = "Widgets" 
 OptionButton2.GroupName = "Widgets" 
 OptionButton4.GroupName = "Widgets" 
 
 OptionButton3.GroupName = "Gadgets-Group2" 
 OptionButton5.GroupName = "Gadgets-Group2" 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.