Please Donate for Our Developers to Keep Macro and Add-Ins Free Forever !
Excel Tutorial Topics
- All Excel Shortcuts
- Writing Excel Function
- Excel SUM Function
- Excel COUNT and COUNTA Functions
- Excel Length of Formula (LEN)
- Excel Trim Function
- Excel Right, Left and Mid Functions
- Excel Vlookup
- Creating Drop Down List in Excel
- Creating A Simple Macro and Add-In
- Assigning Macro to Button in Excel
- Installing an Add-In- 2010 / 2007 / 2013
- Creating VBA Form in Excel for Data Entry
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.
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.
MsgBox “You have just hit the button.”
Step# 3: Now right click on the rectangle button and click Assign Macro. Select the macro to assign from the list and click OK.
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.