Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 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: Understanding Macros.
by Allen Wyatt
(last updated February 16, 2019)
A macro is similar to a computer program. It consists of a series of instructions that the computer follows in a sequence you specify. The macro is given a name that is used to run the instructions it contains. Excel provides two general ways to create a macro. The first (and easiest) method is to record a macro using the macro recorder. The other method is to write a macro from scratch using the VBA Editor. While writing from scratch is perfectly acceptable, it is often a good idea, especially for smaller macros, to record the basic steps you want performed and then edit the recorded macro to create the final instructions.
Anything you do in Excel that is of a repetitive nature is a good candidate for a macro. For instance, you might have the job of creating financial analysis reports for your company and you want to create a macro that will enter the company name in the current cell and format it using the proper font. Such a task is easily done with a macro.
When you create a macro, you have the opportunity to store it in any of three places. Where you store a macro determines when it is available and how it can be later used. The following are the storage options available in Excel:
Remember that macros are only available if the workbook in which they are stored is open. Thus, only those stored in your Personal Macro Workbook will be available at all times. This works because the Personal Macro Workbook is always open (even if it is not visible). Macros you store in other workbooks are only available if that workbook is open.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8148) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Understanding Macros.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
If you have a macro that takes a long time to process a workbook, you might want to continue working in Excel while the ...Discover More
When creating your own user interfaces within Excel, the various developer controls can add a nice touch. One such ...Discover More
Using macros to step through each cell in a selection is a common occurrence. What if that selected range is made up of ...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.