Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Adding Buttons to Your Worksheet.
by Allen Wyatt
(last updated August 1, 2015)
Probably the most commonly created control object for worksheets is the lowly button. This is because the most common use of buttons is to run macros which you have associated with a workbook. You can insert buttons in your worksheet by use of the Button tool. Follow these steps:
Excel immediately displays the Assign Macro dialog box, offering you the opportunity to assign a macro to the button. Notice that the dialog box presents a list of previously defined macros, along with a suggested name for the macro to be assigned to this button. The suggested name is comprised of the default name of the button itself (something like Button1) combined with the action that will start the macro (Click). This macro name (Button1_Click) will appear very familiar to people that have programmed in Visual Basic before, since it conforms to the standard way of naming event handlers. (Event handlers are nothing but programming code designed to handle a specific event, such as an object—like a button—being clicked with the mouse.)
To complete your work with the Assign Macro dialog box, select a macro you want assigned to this new button and then click on OK. You can then change the title appearing on the button by clicking your mouse within the button text and entering a new title.
Once the button is finished in this manner, the macro associated with this button will be run whenever anyone clicks on it with the left mouse button. If you use the right mouse button instead, you will see a menu that allows you to delete the button or change the macro assigned to the button.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10485) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Adding Buttons to Your Worksheet.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
Want to get rid of all the zero values in a range of cells? This tip provides a couple of different ways you can accomplish ...Discover More
Need to select a cell using a macro? Need that selection to be relative to the cell you currently have selected? Here's the ...Discover More
Excel allows you to hide worksheets so that they aren't visible to those using your workbook. Hiding worksheets has a ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.