Excel UserForm Option Button: Setup and VBA Guide

VBA & macros · Updated November 18, 2026

An Excel UserForm option button (also called a radio button) lets a user choose one item from a group of alternatives. In Excel for Microsoft 365 on Windows, add an OptionButton control in the Visual Basic Editor, place related choices in the same Frame, and read the selected control’s Value in VBA.

What a UserForm Option Button Does

An option button displays a small circle beside a caption. When a user selects it, the circle is filled and its Value becomes True; other buttons in the same group become unselected, with a Value of False. This makes the control suitable for a single choice such as “Email,” “Phone,” or “Mail,” rather than a set of independent yes-or-no choices.

A UserForm is a custom dialog built with VBA. It can collect input, guide a user through a task, and pass the result to a macro or worksheet. An OptionButton is one of several controls available in the Visual Basic Editor’s Toolbox; others include labels, text boxes, check boxes, and command buttons.

The key idea is that the buttons need a defined group. Within a group, selecting one choice deselects the others. Buttons in separate groups can each have a selection at the same time, which is useful when a form asks more than one single-choice question.

How to Add an Option Button to a UserForm

  1. Open the workbook in desktop Excel and press Alt+F11 to open the Visual Basic Editor. On a Mac, use Option+F11 (you may need to hold Fn), or use Excel’s Tools > Macro > Visual Basic Editor menu if the shortcut differs on your keyboard.
  2. In the editor, choose Insert > UserForm. If the Toolbox is not visible, choose View > Toolbox.
  3. Select the OptionButton control in the Toolbox, then click or drag on the form to place it. Repeat for each answer in the group.
  4. Select a button and open the Properties window with F4. Set (Name) to a useful code name, such as optEmail, and set Caption to the text the user should see, such as Email.
  5. Arrange the choices clearly, then add a CommandButton if the user should submit the selection. Double-click that button to create its Click event procedure.

Use names that describe purpose rather than appearance. For example, optStandard is more informative in code than OptionButton1. The Name is used by VBA; the Caption is the visible label. Changing one does not automatically change the other.

Group Choices with Frames

The simplest way to make separate question groups is to add a Frame for each question and put its OptionButtons inside it. For example, put “Email,” “Phone,” and “Mail” inside a frame captioned “Preferred contact method,” then put “Morning,” “Afternoon,” and “Evening” inside a second frame captioned “Best time to call.” The user can select one choice in each frame.

OptionButtons that share the same parent container are normally treated as one group. Thus, buttons placed directly on the UserForm generally act as one group, while buttons placed inside different Frames act as separate groups. A Frame is not merely a decorative border: it also provides a clear visual and logical boundary for its contents.

The OptionButton control also has a GroupName property that can be used to specify group membership. A Frame is usually easier to understand and maintain, especially for a form with multiple questions. If you use GroupName, give the intended members the same nonblank group name and check the form’s behavior; do not mix grouping approaches casually, because a control’s container and group settings affect how choices interact.

Read the Selected Choice in VBA

VBA reads an option button’s selection through its Value property. The following example assumes a UserForm has three OptionButtons named optEmail, optPhone, and optMail, plus a CommandButton named cmdSubmit. The three choices should be in the same group, such as one Frame.

Private Sub UserForm_Initialize()
    ' Set a clear default choice when the form opens.
    optEmail.Value = True
End Sub

Private Sub cmdSubmit_Click()
    Dim contactMethod As String

    If optEmail.Value Then
        contactMethod = "Email"
    ElseIf optPhone.Value Then
        contactMethod = "Phone"
    ElseIf optMail.Value Then
        contactMethod = "Mail"
    Else
        MsgBox "Choose a contact method first.", vbExclamation, "Selection required"
        Exit Sub
    End If

    MsgBox "Selected: " & contactMethod, vbInformation, "Contact method"
End Sub

The Initialize event runs when the form is loaded, so this example selects Email as the initial choice. When the user clicks Submit, the code checks each Value and stores the matching caption in a string. The final message is only an illustration; replace it with the action your workbook needs, such as writing a value to a worksheet or choosing a different processing path.

When writing a result to a worksheet, decide deliberately which sheet and cell should receive it. For instance, a form could write the selected text to a designated input cell after validation. Avoid relying on whichever sheet happens to be active unless that is an intentional part of the design; explicit worksheet references make a macro less likely to put data in the wrong place.

Useful Properties and Form Design

  • Caption: The user-facing wording. Keep it short and make each alternative distinct.
  • Name: The identifier used in VBA. Use consistent prefixes such as opt for option buttons.
  • Value: True when selected and False when not selected. Set one Value to True to establish a default.
  • Enabled: Set to False when an option is unavailable. Disabled choices should have a clear explanation so users understand why they cannot select them.
  • Visible: Controls whether the option appears. Hiding an option dynamically can affect the choices available, so confirm that at least one valid answer remains.
  • TabIndex: Helps determine the order in which keyboard users move through controls. Arrange it to follow the visual reading order.

Write captions as complete, understandable choices rather than unexplained abbreviations. If the alternatives need extra detail, use a nearby Label or a short introductory prompt. Keep the default neutral when one answer should not be favored; if a default is useful, make it obvious and ensure the user can change it. A UserForm should also provide a way to cancel or close without submitting an unintended choice.

Common Problems and How to Fix Them

  • Several choices remain selected: Check that the buttons are in the same Frame or otherwise have the intended group settings. Buttons in different Frames are expected to allow independent selections.
  • The code cannot find a control: Confirm the code uses the control’s (Name), not its Caption. For example, a button captioned “Email” might still be named OptionButton1 unless you change it.
  • The wrong choice is returned: Check the control names and the order of the If statements. Also make sure the submit code is in the intended form’s CommandButton Click event, not in a similarly named procedure elsewhere.
  • The form opens with an unexpected selection: Look for assignments to Value in Initialize or other event procedures. Set the intended default explicitly, or set all choices to False if the question should begin unanswered.
  • A click does not submit the form: Verify that the submit control is a CommandButton and that the procedure name matches its Name property, for example cmdSubmit_Click. A renamed control may require its event procedure to be recreated or corrected.
  • The form works in the editor but not for another user: Save the file in a macro-enabled format such as .xlsm, and ensure macros are permitted by the recipient’s security settings. A normal .xlsx workbook cannot store VBA code.

VBA macros cannot be undone with Ctrl+Z. Before running a macro that changes worksheet data, save a copy of the workbook and, when practical, test the form on sample data first.

Option Buttons Compared with Check Boxes and Drop-Downs

Choose an OptionButton when exactly one answer should be selected from a small, visible set. A CheckBox is better when answers are independent and users may select none, one, or several—for example, separate preferences for “Email updates” and “Text reminders.” Check boxes do not automatically exclude one another.

A ComboBox or ListBox is often more suitable when there are many choices or screen space is limited. A drop-down keeps a long list compact, while a ListBox can show several choices at once. These controls require slightly different VBA handling, but the principle remains: present choices in a form that matches whether the user may select one item or multiple items.

A common misconception is that an option button’s circle can be clicked independently of its group. The circle is the visible control, but selection behavior is determined by the group: clicking one member changes the state of the others in that group. If the form needs multiple selections, use check boxes instead of making multiple option buttons appear to work independently.

Excel for Mac and Excel for the Web

UserForms are VBA features for desktop Excel, not worksheet controls that run in every Excel edition. Excel for Microsoft 365 on Windows supports creating and using VBA UserForms. Excel for Mac also supports VBA and UserForms, although the editor interface, keyboard shortcuts, and some control capabilities can differ; check the form on the Mac version your audience uses.

Excel for the web does not run VBA macros or display VBA UserForms. Saving an .xlsm workbook in a cloud location does not make its UserForm usable in a browser. If people must complete the process in Excel for the web, consider a worksheet-based input layout or another supported data-entry tool instead.

Frequently Asked Questions

How do I make an option button selected by default?

Set its Value to True, usually in the UserForm’s Initialize event. For example, use optEmail.Value = True when the button is named optEmail. In a single group, this selects that choice when the form opens.

Can a UserForm have more than one group of option buttons?

Yes. Put each question’s buttons in a different Frame, or use the GroupName property appropriately. Each group can have one selected option, so a form can collect answers to several separate single-choice questions.

What is the difference between an OptionButton and a CheckBox?

An OptionButton is for choosing one alternative from a group; selecting another member replaces the previous selection. A CheckBox represents an independent on/off choice, so several check boxes can be selected at once.

How do I find which option button the user selected?

Check the Value property of each button in the group. The selected button has Value set to True. In a submit-button event, test the options with If and ElseIf statements, then use the matching result.

Will a UserForm option button work in Excel for the web?

No. Excel for the web does not run VBA UserForms. The workbook must be opened in desktop Excel to use its VBA form; browser-based users need a different input method.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.