13. Automating Repetitive Tasks with Macros
Chapter at a Glance
Many tasks you perform in Microsoft® Office Excel® 2007 (for example, entering sales data for a particular day or adding formulas to a worksheet) are done once or (for example, changing the format of a cell range) can be repeated quickly using available tools in Office Excel 2007. However, you will often perform one or two tasks frequently that require a lot of steps to accomplish. For example, you might have a number of cells in a worksheet that contain important data you use quite often in presentations to your colleagues. Instead of going through a lengthy series of steps to highlight the cells with the important information, you can create a macro, or a recorded series of actions, to perform the steps for you. After you have created a macro, you can run, edit, or delete it as needed.
In Excel 2007, you run and edit macros using the items available in the View tab's Macros group. You can make your macros easier to access by creating new buttons on the Quick Access Toolbar, to which you can assign your macros. If you run a macro to highlight specific cells in a worksheet every time you show that worksheet to a colleague, you can save time by adding a Quick Access Toolbar button that runs a macro to highlight the cells for you.
Another handy feature of Excel 2007 macros is that you can create macros that run when a workbook is opened. For example, you might want to ensure that no cells in a worksheet are highlighted when the worksheet opens. You can create a macro that removes any special formatting from your worksheet cells when its workbook opens, enabling you to emphasize the data you want as you present the information to your colleagues.
In this chapter, you'll learn how to open, run, create, and modify macros; create Quick Access Toolbar buttons and shapes that enable you to run macros with a single mouse click; define macro security settings; and run a macro when a workbook is opened.
Do you need only a quick refresher on the topics in this chapter? See the Quick Reference entries on pages xxviilxiii.