To complete many tasks in Excel, you need to execute a series of commands and actions. To print two copies of a selected range of Sheet2 of a worksheet, for example, you need to open the workbook, switch to Sheet2, select the print area, open the Print dialog box, and specify that you want to print two copies. If you often need to complete the same task, you'll find yourself repeatedly taking the same series of steps. It can be tiresome to continually repeat the same commands and actions when you can easily create a mini-program, or macro, that accomplishes all of them with a single command.
Creating a macro is easy and requires no programming knowledge on your part. Excel simply records the steps you want included in the macro while you use the keyboard and mouse. When you record a macro, Excel stores the list of commands with any name you choose. You can store your macros in the current workbook, in a new workbook, or in Excel's Personal Macro workbook. Storing your macros in the Personal Macro workbook makes the macros available to you from any location in Excel, even when no workbook is open.
Once a macro is created, you can make modifications to it, add comments so other users will understand its purpose, and test it to make sure it runs correctly.
You can run a macro by choosing the Macro command on the Tools menu, or by using a shortcut key or clicking a toolbar button you've assigned to it. When you click the Tools menu, point to Macro, and then click Macros, the Macro dialog box opens. From this dialog box, you can run, edit, test, or delete any Excel macro on your system, or create a new one.
If you have problems with a macro, you can step through the macro one command at a time, known as debugging . Once you identify any errors in the macro, you can edit it.