Chapter 21. Using Macros

In This Chapter

  • Understanding how macros work

  • Recording macros in a worksheet

  • Using the relative references when recording macros

  • Assigning macros to custom buttons on the Quick Access toolbar

Macros enable you to automate almost any task that you can undertake in Excel. By using Excel's macro recorder to record tasks that you perform routinely, you not only speed up the procedure considerably (as Excel can play back your keystrokes and mouse actions much faster than you perform them manually), but you are also assured that each step in the task is carried out the same way each and every time you perform the task.

In this chapter, you get a chance to practice recording, testing, and playing back macros that you use to automate repetitive tasks required when building and using your Excel worksheets and charts. You also have the opportunity to practice assigning the macros you record to custom buttons on the Quick Access toolbar.

Creating Macros

You can create macros for your Excel spreadsheets in one of two ways:

  • Use Excel's macro recorder to record your actions as you undertake them in a worksheet

  • Enter the instructions that you want followed in VBA code in the Visual Basic Editor

Either way, Excel creates a special module sheet that holds the actions and instructions in your macro. The macro instructions in a macro module (whether recorded by Excel or written by you) are stored in the Visual Basic for Applications programming language. You can then study the VBA ...

Get Excel® 2010 Workbook for Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.