Please Donate for Our Developers to Keep Macro and Add-Ins Free Forever !

Excel Tutorial Topics

Free Excel Bee Macro & Add-Ins

Assigning Macro to Button in Excel

Do you want a button to run a VBA macro in excel?
Remembering shortcuts for each and every macro is not easy so you probably required buttons with label to recognize macros and easily run them. Today we will learn how we can assign a VBA macro to a button in worksheet. We will learn it in just three easy steps. Although you can Add or assign a button to macro in almost all version of MS Excel like Excel 20013, 2010, 2007 and 2003 but we are considering Excel 2007 menu to explain example here.

Step# 1: Go to Insert menu and click on the shapes then choose Rectangle shape and give it name by edit text in mouse right click option.

Create Excel Button for Macro

Step# 2: Now record a simple macro to test, if you have not any macro recorded. You can also open the VBA console window by pressing Alt + F11 and paste the below macro code.

Sub Macro1()
MsgBox “You have just hit the button.”
End Sub

Step# 3: Now right click on the rectangle button and click Assign Macro. Select the macro to assign from the list and click OK.

Excel Macro Assign

Once macro is assigned to button, cursor will change to hand on hovering the button. If you want format button, move button or assign another macro to the button, you can do it from the options available on mouse right click.

Where you can use it?

You can best use it as a calculator button like you must have seen simple accounting application which has excel cells for input and submit button to runs a macro that calculate and give you output.