1. Add Excel Command Button from Quick Access Toolbar
This is Applicable for Excel 2007 and above versions.
This page has quick tips to insert command button in Excel from (1) quick access toolbar & (2) developer tab. Follow these steps to know more…
1. To insert the command button or any other controls, add “Insert Controls” in the Quick Access Toolbar as explained in this post.
2. Once the Control is added, click on “Insert Controls” to view what are the available commands that can be inserted in worksheet.
3. Click on Commands Button and draw the control on Excel Sheet.
4. Double click on Command after adding, to insert VBA Macro code for the newly inserted control.
Using this method, Form Controls & ActiveX Controls can be added to a Excel worksheet or MS Word document.
2. Adding Command Button From Developer Tab
To add controls to Excel sheet & control the macro code, add developer tab to Excel as explained in this link.
Once developer tab appears on Excel menu, follow these steps.
- Click ‘Developer’ tab in Menu.
- Select ‘Insert Controls’.
- Click ‘Command Button’ in Activex controls.
- Click & Draw command button on Excel Sheet.
- Double click on command button to add VBA code.
Double clicking on Activex control will open vb editor to write the code behind the control button. If we add form control, we can assign a macro to the control.
Enable design mode to write the code. Disable design mode, click on the control to test whether the control is able to execute the vba code properly.
Remember to save the workbook with .xlsm (macro enabled Excel) mode. Then only the vba code project will be saved along with Excel. Else you will end up in loosing the code.