VBA option button control in Excel

Option button, as the name indicates, is a kind of button that enables the user to select any one option only.

This button, when used more than one in a form, allows the user to select only one.

This control is normally found in many web sites and other VB applications like,

Gender selection, yes or no and so on.

This button is often used in variety of excel application.

The optionbutton values are predefined and cannot be modified by the end user.

Option Button Groups

If in an application, if the user need to enter more than one option inputs, say male or female and yes or no,

then, optionbuttons are grouped together to act as two separate set of controls.

The Frame control is used to group option buttons, as shown below:

excel vba option button control

As seen from the above, there are now two groups of option buttons which are placed inside a frame.

The option button also has the same properties as that of other controls discussed earlier such as:






and many more.

The important event associated with that of option button is "Change" event.

This event is triggered whenver an option button options is changed.

The following example illustrates this

  1. Private Sub OptionButton1_Change()
  2. MsgBox "Change event triggered by selecting 'Yes' "
  3. End Sub
  1. Private Sub OptionButton2_Change()
  2. MsgBox "Change event triggered by selecting 'No' "
  3. End Sub
  1. Private Sub OptionButton3_Change()
  2. MsgBox "Change event triggered by selecting 'Male' "
  3. End Sub

excel vba option button control


You can find similar Excel Questions and Answer hereunder

1) Here an explanation about spin button and how to control it using VBA

2) Here an explanation about text box and how to control text boxes in Excel VBA

3) Here an explanation about checkbox and how to control checkboxes in Excel VBA

4) Here an explanation about label controls in the various forms and controls using VBA

5) Here an explanation about buttons in VBA

6) What are ActiveX controls in VBA. Here some good explanations

7) Here an explanation about list box and how to control list boxes in Excel VBA

8) Here an explanation about frames and how to control frames in Excel VBA

9) Here an explanation about combo boxes and interfacing with your user in Excel VBA

10) How to control forms in Excel VBA


Here the previous and next chapter