You can use a button (a form control) to run a macro (macro: An action or a set of actions that you can use to automate tasks. Macros are recorded in the Visual Basic for Applications programming language.) that performs an action when a user clicks it. For example, you might use a button to automate the printing of a worksheet, the filtering of data, or the calculation of numbers. The following procedure assumes that you've created a macro already.
- On the Developer tab, in the Forms Control group, click Button.
If the Developer tab is not available
- On the right side of the ribbon, click , and then click Ribbon Preferences.
- Under Customize, select the Developer check box.
- Click the worksheet location where you want the upper-left corner of the button to appear.
- To create the button, drag in the sheet.
- In the Assign Macro dialog box, click the name of the macro that you want to assign to the button, and then click OK.
- To specify the control properties of the button, hold down CONTROL and click the button, and then click Format Control.
- To test your button, click it. Your macro should run.
Create, run, edit, or delete a macro