You can also assign a macro to a button (Form Control). When a macro is assigned to the control, that macro is executed, or played, when the control is clicked.
Take a moment to assign a button for the Helloworld macro you created earlier. Here’s how:
- On the Developer tab, click the Insert button in the Controls group.
- Select the Button Form Control.
- Click the location on the worksheet where you want to place your button.
- In the “Assign Macro” dialog box, select the macro you want to assign to the button and then click OK.
- You can drag the grab handles to resize the button to your preference.
- Right-click the button and click Edit Text, then type a name you like.
- Select any other cell to apply the change.
- Now, you can run this macro by click the button.
Macros can be assigned to any worksheet object, such as a picture, a text box, a shape, SmartArt graphics, WordArt, or an icon. To assign a macro to any object, right-click the object and select Assign Macro.
Form Controls or ActiveX Controls
Although they look similar, they are very different. Form controls are specifically designed for use with spreadsheets, while ActiveX controls are typically used with Excel user forms. As a general rule, you should always use form controls when working with spreadsheets. Why? Form controls require less overhead, so they perform better, and configuring form controls is much easier than configuring their ActiveX counterparts.
Although they look similar, they are very different. Form controls are specifically designed for use with spreadsheets, while ActiveX controls are typically used with Excel user forms. As a general rule, you should always use form controls when working with spreadsheets. Why? Form controls require less overhead, so they perform better, and configuring form controls is much easier than configuring their ActiveX counterparts.