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.
Tech Tip : Get an instant remote access to all your essential documents, files and windows applications from anywhere on any device(PC/Mac/android/iOS) with high performance hosted citrix xendesktop at an affordable xendesktop pricing. Try out MS Azure with managed azure services from Apps4Rent to enhance your work efficiency and team collaboration.
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.