Excel Form Button vs. CommandButton: Which to Use?
In this article
Yes—Excel has a Form Control button that can run a macro, but it is not the same thing as an ActiveX CommandButton. For most simple workbook actions, choose a Form Control button and assign a macro; use an ActiveX CommandButton only when you need its extra event and property options and are working in desktop Excel for Windows.
What Excel means by a form button
Excel’s Form Controls are interactive objects that can be placed on a worksheet. A Button (Form Control) can be linked to a VBA macro, so clicking it runs that macro. It is not a VBA control named CommandButton, and it does not expose the same collection of properties and events as an ActiveX button.
ActiveX controls, including CommandButton, are a separate category of worksheet control. They have design-time properties and VBA event procedures such as a click event. The similar names can be confusing: both controls can look like clickable buttons, but they are configured differently and suit different needs.
Insert and assign a Form Control button
- If the Developer tab is not visible, go to File > Options > Customize Ribbon, select Developer in the Main Tabs list, and choose OK.
- On the Developer tab, select Insert. Under Form Controls, choose Button.
- Drag on the worksheet to draw the button. When the Assign Macro dialog appears, select an existing macro or choose New to create one, then select OK.
- Right-click the button and choose Edit Text to change its label. Click a blank cell to finish editing.
For example, a button labeled “Update report” could be assigned to a macro that refreshes a report or formats a prepared range. The button does not contain that work by itself: the assigned macro supplies the action. If there is no suitable macro, create one in the Visual Basic Editor, then return to the worksheet and assign it.
Macros require a macro-enabled workbook format, usually Excel Macro-Enabled Workbook (*.xlsm). Save a copy before running VBA: macros cannot be undone with Ctrl+Z. Only enable macros in files from sources you trust.
What a CommandButton does differently
An ActiveX CommandButton is configured through its properties and VBA event code. On the Developer tab, choose Insert and then Command Button under ActiveX Controls; draw it on the sheet. Select Design Mode, then right-click the control and choose View Code to add a procedure for its click event. The event is tied to that specific control, rather than selected from the Form Control’s Assign Macro dialog.
ActiveX can be useful when a button’s behavior depends on its properties or when you need to handle several control events. For example, VBA can change an ActiveX button’s caption or enabled state as the workbook changes. Form Control buttons are simpler: assign a macro, set a label, and use the button to call that macro.
For basic use, a Form Control is usually easier to maintain and less dependent on control-specific code. ActiveX introduces additional setup, and it is not supported in Excel for the web. Microsoft 365 for Mac also does not provide the same ActiveX control support as desktop Excel for Windows, so do not choose ActiveX for a workbook that must work consistently across platforms.
Which button should you choose?
- Choose a Form Control button for a straightforward action such as running a macro to print a report, clear specified input cells, or update a worksheet.
- Choose an ActiveX CommandButton if you specifically need its properties or event-driven behavior and the workbook will be used in a compatible Windows desktop version of Excel.
- Choose a shape with an assigned macro if you want a more flexible visual design and only need a clickable object to start a macro.
- Choose a hyperlink or a built-in Excel command if the task is navigation or an ordinary workbook operation that does not need VBA.
When sharing a workbook, consider both the recipient’s Excel version and macro security settings. A button can appear on the sheet but still fail to perform its action if macros are disabled, the macro is missing, or the file is opened in an environment that cannot run that control.
Common problems and fixes
- The button does nothing: For a Form Control, right-click it and select Assign Macro to confirm a macro is assigned. Check that the macro exists in the workbook and that macros are permitted by the recipient’s security settings.
- The button only selects or moves: You may be editing its text or, for ActiveX, have Design Mode turned on. Click outside the object to finish text editing; for ActiveX, turn off Design Mode before testing.
- The Assign Macro dialog does not appear: You may have inserted a shape or an ActiveX control instead of a Form Control button. Check the Insert menu and choose Button in the Form Controls section.
- The control is difficult to select: Right-click the object to access its context menu. For ActiveX controls, Design Mode helps select and edit the control rather than activate it.
- It works on one computer but not another: Check whether the second user is in Excel for the web or on Mac, whether macros are enabled, and whether the workbook has been saved as .xlsm when it contains VBA.
Do not treat a button as a security boundary. A macro that changes or deletes data can have real effects, and a button does not make untrusted VBA safe. Review the code and keep a separate copy of important data before using macros that modify a workbook.
Frequently Asked Questions
Is an Excel Form button the same as a CommandButton?
No. A Form Control button is assigned a macro through Assign Macro. An ActiveX CommandButton has its own properties and can run code through a control event procedure.
Can a Form Control button run VBA?
Yes. Assign it to a VBA macro. The workbook must be saved in a macro-enabled format such as .xlsm, and Excel’s macro settings must allow the code to run.
Can I use a CommandButton in Excel for the web?
ActiveX controls are not supported in Excel for the web. The web version also cannot run VBA macros, so a worksheet button that depends on VBA will not provide its desktop macro action there.
How do I change a Form button’s text?
Right-click the Form Control button, choose Edit Text, and type the label you want. Click a blank cell when finished.
Can I assign a macro to a shape instead?
Yes. Right-click a shape and choose Assign Macro. A shape can provide a custom appearance while serving the same basic purpose of starting a macro, though it is not a Form Control or an ActiveX control.
Bottom line
When someone asks for an “Excel form button as CommandButton,” first clarify whether they mean a clickable worksheet button or the specific ActiveX control. For a simple macro launcher, insert a Button under Form Controls and assign the macro. Use an ActiveX CommandButton only when its extra control features are genuinely needed and the target environment supports it.