Option Button in Excel VBA: Add, Group, and Use It

VBA & macros · Updated November 18, 2026

Yes. In Excel for Microsoft 365 on Windows, add an option button from Developer > Insert, then choose either a Form Control or an ActiveX control; to create one with VBA, use the Shapes.AddFormControl method. Option buttons let someone choose one item from a set, and the right way to link and group them depends on which control type you use.

What an Excel option button does

An option button, also called a radio button, presents a labeled choice that can be selected or cleared only by selecting another choice in its group. For example, a form might offer “Standard,” “Express,” and “Pickup.” Unlike check boxes, which allow multiple independent selections, option buttons communicate that the choices are mutually exclusive.

Excel has two kinds of worksheet option buttons: Form Controls and ActiveX Controls. Both can be added through the Developer tab, and both can be used with VBA, but their properties and behavior are not identical. Form Controls are generally the simpler choice for a basic worksheet form. ActiveX controls offer more properties and event handling, but can be more sensitive to security settings and are not supported in Excel for Mac.

Choose an option button when a reader should make exactly one selection. If they should be able to select several answers, use check boxes instead. If the list is long, a drop-down list may take up less room and be easier to maintain.

Show the Developer tab and insert a control

If Developer is already visible on the ribbon, skip the first step. On Windows, enable it from File > Options > Customize Ribbon, select the Developer check box under Main Tabs, and choose OK. Then use these steps:

  1. Open the worksheet where the choices should appear.
  2. Select Developer > Insert.
  3. Under Form Controls, select Option Button, or choose Option Button under ActiveX Controls.
  4. Click or drag on the worksheet to place the control. Dragging gives you more control over its size.
  5. Right-click the new button and choose Edit Text to replace its default label.
  6. Repeat for each choice, then arrange the controls so their labels are easy to read.

Use Form Controls for a straightforward choice that writes a result to a linked cell. Use ActiveX when you specifically need control properties or events such as a button’s Click event. Do not confuse an option button with a command button: an option button records a choice, while a command button runs an action.

Excel for the web does not provide the desktop VBA editor or run VBA macros. The Developer ribbon and control options can also differ by platform. On Mac, ActiveX controls are unavailable; use a supported Form Control or a worksheet-based alternative. Ribbon labels and preferences can vary slightly across Excel for Mac releases.

Create a Form Control option button with VBA

A macro can add a Form Control option button to a worksheet. The following example adds one button near the upper-left corner of the sheet named Sheet1, gives it a label, and connects it to cell B1. Change the worksheet name and position to suit your workbook.

Option Explicit

Sub AddFormOptionButton()
    Dim ws As Worksheet
    Dim opt As Shape

    ' Add a copy of the workbook before running this macro.
    Set ws = ThisWorkbook.Worksheets("Sheet1")
    Set opt = ws.Shapes.AddFormControl( _
        Type:=xlOptionButton, Left:=30, Top:=40, Width:=120, Height:=20)

    ' Set the displayed label and the linked result cell.
    opt.TextFrame.Characters.Text = "Standard"
    opt.ControlFormat.LinkedCell = "$B$1"
End Sub

To enter the macro, press Alt+F11 on Windows to open the Visual Basic Editor, choose Insert > Module, and paste the code into the module. Run AddFormOptionButton from the editor or from Excel’s Macro dialog. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) if you need to keep the VBA project.

This example creates one control each time it runs, so running it repeatedly adds more buttons rather than updating the existing one. Delete the extra controls or modify the macro to check for an existing shape before adding another. Save a copy of the workbook before running any macro: VBA changes cannot be reversed with Ctrl+Z.

Link the selection to a cell

A linked cell gives the worksheet or a macro a way to read the selected choice. With a Form Control option-button group, the linked cell contains a number identifying the selected button: the first option is 1, the second is 2, and so on. For example, if the choices are Standard, Express, and Pickup, selecting Express generally puts 2 in the group’s linked cell. The number reflects the button’s position in the group, not its caption.

For Form Controls, select a button, right-click it, choose Format Control, and use the Control tab to set the Cell link. Set the same link for the buttons in that group. Keep the cell somewhere sensible: it can be placed in a helper area or hidden column, but avoid hiding it so thoroughly that you forget where the result is stored.

ActiveX option buttons have a LinkedCell property too, but their linked-cell behavior is different: the selected control is represented as TRUE and the unselected controls as FALSE. Do not assume that a Form Control’s numeric result and an ActiveX control’s Boolean result can be interpreted in the same way. When reading a result in VBA, first establish which control type the sheet uses.

Group choices so they do not interfere

Grouping determines which buttons turn each other off. Form Control option buttons on a worksheet normally belong to the same group unless you separate sets with a Group Box. To add one, select Developer > Insert > Group Box under Form Controls, draw the box around a set of options, and place that set’s buttons inside it. Add a separate group box for another independent question. A frame is not just decoration here: placing controls inside the intended box defines their selection group.

ActiveX controls can be grouped using their GroupName property. Give the buttons for one question the same group name, and use another name for a separate question. This matters on a form with multiple questions: without separate groups, a selection in one question can unexpectedly clear a selection in another. Keep each group’s labels and controls visually together so the relationship is obvious to the person filling in the sheet.

Test each group after adding it. Select each option in turn and confirm that only one button in that group remains selected, while a selection in a different group stays intact. Also verify that the linked cell or cells update as expected.

Read the selected answer in VBA

For a Form Control group linked to B1, VBA can use the stored index in a Select Case statement. The example below assumes the three choices are numbered in the displayed order: 1 for Standard, 2 for Express, and 3 for Pickup.

Option Explicit

Sub UseDeliveryChoice()
    Dim ws As Worksheet
    Dim choice As Long

    Set ws = ThisWorkbook.Worksheets("Sheet1")
    choice = CLng(ws.Range("B1").Value)

    ' Respond to the selected Form Control option.
    Select Case choice
        Case 1
            MsgBox "Standard delivery selected."
        Case 2
            MsgBox "Express delivery selected."
        Case 3
            MsgBox "Pickup selected."
        Case Else
            MsgBox "Select a delivery option first."
    End Select
End Sub

The Case Else branch is useful because the linked cell may be blank before a choice is made, or may contain an unexpected value if the controls have been changed. If you change the order or add options, update the mapping in the macro. For a more maintainable workbook, document which number corresponds to each label near the control group or in the VBA comments.

Format and maintain the controls

Option buttons are objects positioned over the worksheet grid, not values stored inside cells. As a result, changing row heights, column widths, or zoom can affect how neatly they line up. Use consistent spacing, keep each label short enough to read, and leave room for longer translated or revised text. Right-click a Form Control and use Format Control to adjust its properties; ActiveX formatting is available through its Properties window while Design Mode is on.

Consider how controls behave when cells move or the sheet is printed. Right-click a Form Control, choose Format Control, and review the Properties tab to set whether it moves or resizes with cells. Protecting a worksheet can also affect whether people can change controls; test the protected sheet using the permissions intended for its users. A linked cell can be hidden from view, but the button still depends on it to store a result.

Common problems and practical checks

  • A button does not respond: If it is an ActiveX control, check whether Design Mode is on. Turn it off on Developer > Design Mode to interact with the control. Also check whether macros or ActiveX content are blocked by the workbook’s security settings.
  • Selecting one choice clears another question: The controls are probably in the same group. Put separate Form Control sets in separate Group Boxes, or assign distinct GroupName values to ActiveX controls.
  • The linked cell shows a number instead of the label: That is normal for a Form Control group. Use a Select Case statement to translate the index into a readable response, or display the chosen label in another cell.
  • The linked cell is blank or does not change: Check that the cell link is set on every relevant Form Control, that the selected controls share the intended group, and that you are looking at the right cell.
  • The macro cannot find the sheet: Confirm that the worksheet tab is actually named Sheet1, or replace that string in the code with the exact tab name. A renamed or deleted sheet causes the reference to fail.

Macros and ActiveX controls can be restricted by Trust Center settings or organizational policy. Only enable content in workbooks you trust, and do not lower security settings just to make an unknown file run. If a workbook is shared, check that recipients’ Excel versions support the controls and that the file format preserves the VBA project.

When another control is a better fit

Option buttons are clearest when there are only a few mutually exclusive choices and all choices should be visible at once. For a long list, a data-validation drop-down may use less worksheet space. In Excel for Microsoft 365 on Windows, create one with Data > Data Validation, set Allow to List, and provide the source values. A drop-down is a cell feature rather than a floating control, so it is often easier to copy down a table or use in a compact form.

Use check boxes when choices are independent, such as “Include a receipt” and “Send a confirmation.” Use a command button when a user should run a macro, and a drop-down when the options are numerous or the sheet needs to remain uncluttered. Picking the control based on the choice behavior helps avoid confusing users and reduces the VBA needed to interpret the answer.

Frequently Asked Questions

How do I add an option button in Excel VBA?
Use the Developer tab to insert a Form Control or ActiveX option button manually, or use VBA’s Shapes.AddFormControl method to add a Form Control. Set a label and link the control or group to a worksheet cell so you can read the selection.

What does an option button return in Excel?
A Form Control group writes a number representing the selected button to its linked cell. ActiveX option buttons use Boolean-style linked-cell values, with the selected control represented as TRUE. Check the control type before writing code to interpret the result.

How do I make two sets of option buttons work independently?
For Form Controls, put each set inside its own Group Box. For ActiveX controls, assign a different GroupName to each set. Test both groups after arranging the controls to ensure one question’s selection does not clear another’s.

Can I use Excel VBA option buttons on a Mac or in Excel online?
ActiveX controls are not available in Excel for Mac, and Excel for the web does not run VBA macros. Desktop Excel on Mac supports VBA in general, but control availability differs; use a supported Form Control or a cell-based list where cross-platform behavior matters.

Can I undo a macro that adds an option button?
No. Excel’s Ctrl+Z undo history does not reverse VBA actions. Save a copy before running a macro, then remove an unwanted control manually or restore the saved copy.

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.