In Excel, users can add macro-enabled buttons on the worksheets and can run macros by just clicking on them.
Users can use these macro-enabled buttons to perform several different tasks like filtering data, selecting data, printing a worksheet, running formulas, and calculations just by clicking on the buttons.
Adding buttons and embedding the macros to them is easier. Excel has multiple ways to add the macro-enabled buttons to the worksheet. Below, we have some quick and easy ways mentioned for you to add the macro buttons in Excel.
Add Macro Buttons Using Shapes
Users can create buttons in excel using shapes. Creating buttons using shapes has more formatting options over the buttons created from Control buttons or ActiveX buttons. Users can change the design, color, font, and style of the button created using shapes.
- First, go to the “Insert” tab and then click on the “Illustrations” icon” then click on the “Shapes” option and select any rectangle button.
- After that, with the help of a mouse, draw the rectangular button on the worksheet.
- Now, to enter the text in the button, double-click on the button and insert the text.
- For formatting, go to the “Shape Format” tab and you will get multiple options for the formatting of the button.
- From here, you can format the font style, font color, button color, button effects, and much more.
- To edit the text, add the hyperlink, or add the macro, just right-click on the button and you will get the pop-up menu with multiple options.
- From here, you can edit the text, add the hyperlink, and can add the macro to the button.
- Now, select the “Assign Macro” option to add the macro to the button.
- Once you select the “Assign Macro” option, you will get the “Assign Macro” dialogue box opened.
- From here, select the macro and click OK.
- At this point, the button has become micro enabled, and when you move your cursor on the button, the cursor turns to the hand point cursor.
- To freeze the button movement, right-click on the button and select the “Format Shape” and select the option “Don’t move or size with cells”.
Add Macro Buttons Using Form Controls
- First, go to the “Developer” tab and click on the “Insert” icon under the “Control” group on the ribbon.
- After that, select the first button option from the “Form Controls” menu and draw a button on the worksheet.
- Now, select or type the macro name from the “Assign Macro” dialogue box and click OK.
- If you don’t have any macro created yet, you can click cancel to add the macro at a later stage.
- From here, right-click on the button and select “Assign Macro” to add the macro to the button if did not assign yet.
- To format the button font size, style, color, etc. select the “Format Control” option.
- Once you click on “Format Control”, you will get the “Format Control” window open and then can do the button font formatting.
- To freeze the button movement, select the “Properties” tab and select the option “Don’t move or size with cells” and click OK.
Add Macro Buttons Using ActiveX Controls
- First, go to the “Developer” tab and click on the “Insert” icon under the “Control” group on the ribbon.
- After that, select the first button option from the “ActiveX Controls” menu and draw a button on the worksheet.
- Now, to create and insert the macro to the button, click on the “View Code” icon to launch the VBA editor.
- Now, select the” CommandButton1” on the subprocedure and choose the “Click” option from the drop-down list on the right side of the editor.