How to Record and Run a Macro
Part 1: Introduction to Macros
By John Cellini
Published on August 31, 2007
If you find yourself manually performing a series of repetitive actions in Excel, you can save time by creating a macro. Technically, a macro is a VBA procedure (a group of VBA statements that performs a task or returns a result). VBA (Visual Basic for Applications) is the programming language of Excel. If you are not a VBA programmer, don't worry! If you are an Excel user, even at the beginning level, you can create a macro with Excel's Macro Recorder and Excel will write the VBA code for you. Any task that you perform with a series of keystrokes and mouse clicks can be recorded as a macro and executed as a single command.
The objective of this tutorial is to teach you how to record and run a macro. The best way to get started is to jump right in and record a simple macro. In Part 1, we will record a macro. The purpose of this exercise is to give us an overview of the steps and procedures involved in the creation of a macro. In Part 2, we discuss in detail the steps involved in recording a macro. Since you will have already created a simple macro in Part 1, you will be able to more easily understand the concepts involved in recording a macro. In Part 3, we discuss the various ways you can run a macro.
Let's get started! We will create a macro that will enter your company name and the date in a new workbook. The date will indicate when the workbook was first created and will not automatically update to the current date. Here are the steps we will follow:
- Select A1 (even if it is already selected, click on it)
- Type: iCellini Computer Training (or your company name)
- Click the Enter button (the green check mark to the left of Formula Bar
- Format text as follows: size 14 font, bold, italic, blue font color
- Select A2
- Type the today function: =today()
- Click the Enter button on the Formula Bar
- Copy cell A2 (just click the copy button on the Standard toolbar or press Ctrl + c)
- Open the Paste Special dialog box (Edit --> Paste Special)
- Select the Values radio button
- Click OK to close the Paste Special
- Press escape to turn off the "marching ants" border around A2
- Move the focus to A4 by clicking on it
- Click the Stop Recording button on the macro toolbar
Before we go any further, you should practice. Go ahead and following the steps above to enter and format your company name in A1 and enter the current date in A2. Once you are well-acquainted with the steps, proceed with the tutorial.
Open a new workbook and save it as macro_practice.xls. Open the Record Macro dialog box by clicking on the Tools menu, pointing to Macro, and then clicking on Record New Macro.

Before we start recording, we need to provide information about our macro. First, enter the name of the macro: CompanyName_Date. The name cannot have any spaces in it. Next, press Tab on your keyboard or click in the Shortcut key text box. Press Shift and then press C. We have just assigned a keyboard shortcut to run the macro. Store the macro in This Workbook. Finally, write a description of what the macro does. Your Record Macro dialog box should look like the above graphic. Click OK.
page 1 | 2 | next page >>