In this article, we shall learn how to assign a Macro to a button in Excel. Let’s start.
This article is part of my series: Excel VBA & Macros – A Step by Step Complete Guide.
Table of Contents
(Step by Step) How to Assign a Macro to a Button in Excel
After you have recorded and tested a macro, you may want to assign your macro to a button placed in a worksheet. You can follow these steps to do so:
- If your macro is a general-purpose macro and you plan to use it in more than one workbook, make sure that this macro is stored in your Personal Macro Workbook.
- Choose Developer ➪ Controls ➪ Insert, and then click the icon identified as Button (Form Control). To find out the form control button, move your mouse pointer over the icons, and you will see a ToolTip that will describe the control. See the following figure.
- Now select the worksheet and drag in the worksheet to draw the button. Whenever you release the mouse button, the Assign Macro dialog box will appear.
- Select the macro from the list.
- Click OK to close the Assign Macro dialog box.
- A button will appear in the worksheet. You can change the text that is displayed on the button to make it descriptive. To do so, right-click the button, choose Edit Text from the shortcut menu, and make your changes.
After performing these steps, select any cell in the worksheet and click the button to execute the assigned macro in it.
Download Working File
Happy Excelling 🙂