Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. 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: Editing Macros.
by Allen Wyatt
(last updated February 20, 2021)
Taking a look at the programming code used in a macro (either ones you have recorded or macros created by others) is a great way to help you understand how the macro is put together and how it works. You can do this examination, and make changes to your macros, by editing them. To edit a macro you first need to display the Macro dialog box. The easiest way to do this is to simply press Alt+F8. (See Figure 1.)
Figure 1. The Macro dialog box.
In the list of available macros you should choose the macro you want to edit. When you have selected one, you can click on the Edit button and the VBA Editor is displayed with the selected macro loaded and ready to edit.
Once your macro is displayed, you can make changes to it as desired. You use many of the same editing functions you use when making changes to a regular worksheet. Unless you fully understand the consequences of your changes, it is typically best to stick to recording simple macros. If you feel adventurous, however, there is nothing wrong with making changes to your macros to see what they will do. If you do so, it is a good idea to keep these tips in mind:
If you keep these tips in mind, there is very little chance that you will hurt anything. In fact, your chances of learning more about Excel and macro programming are much greater than the risk of damaging any data. Give it a try!
When you have finished making changes to your macro, you should close the VBA Editor. Closing the VBA Editor is done in the same manner as when you close any other Windows program—simply click on the Close icon in the upper-right corner of the window.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9753) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Editing Macros.
Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!
You can use the Zoom feature of Excel to magnify what Excel shows of your workbook, but it affects the entire screen. ...Discover More
When processing a worksheet with a macro, it may be helpful to periodically recalculate the worksheet. Wouldn't it be ...Discover More
You can create macros that are automatically executed whenever certain events occur within a worksheet. This tip details ...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.