How to Assign a Macro to a Button in Excel

In this lesson you can learn how to assign macro to a button (or other object).

A button

To assign a macro to a button in Excel, follow these steps:

First let's prepare some button. Go to Ribbon > Insert > Shapes and select Rectangle.


Insert Rectangle Shape

Then insert the shape in the workbook and name it (if you want).

Insert Rectangle Button

A macro

Now right-click on this button and click Assign macro.

Assign macro

Dialog box appears. Choose the macro which you want to assign.

Assign Example Macro

Macro is now assigned to the button. To run the macro just click the button. Once you've finished customizing the button, you can test it by clicking on it. The macro you assigned should run, and you should see its effects in the worksheet.

To unassign macro right-click on the button. Click Assign macro from the list. Dialog box appears. To unassign the macro just erase macro's name and leave it blank.

Unassign Macro

These steps should help you assign a macro to a button in Excel. This can be a convenient way to run macros that you use frequently, as you won't need to go through the macro dialog box to run them. Simply clicking the button will activate the macro, saving you time and effort.