Microsoft Office Tutorials and References
In Depth Information
Automating Commands with Macros
To see how easy it is to create a macro with the macro recorder, follow these
steps for creating a macro that enters the company name in 12-point, bold
type and centers the company name across rows A through E with the Merge
and Center feature:
1. Open the Excel workbook that contains the worksheet data or chart
you want your macro to work with.
If you’re building a macro that adds new data to a worksheet (as in this
example), open a worksheet with plenty of blank cells in which to add
the data. If you’re building a macro that needs to be in a particular cell
when its steps are played back, put the cell pointer in that cell.
2. Click the Record Macro button on the Status bar.
The Record Macro dialog box opens, similar to the one shown in Figure
12-4, where you enter the macro name, define any keystroke shortcut,
select the workbook in which to store the macro, and enter a
description of the macro’s function.
to record in
3. Replace the Macro1 temporary macro name by entering your name
for the macro in the Macro Name text box.
Remember that when naming a macro, you must not use spaces in the
macro name and it must begin with a letter and not some number or
punctuation symbol. For this example macro, you replace Macro1 in the
Macro Name text box with the name Company_Name.
Next, you can enter a letter between A and Z that acts like a shortcut key
for running the macro when you press Ctrl followed by that letter key.
Just remember that Excel has already assigned a number of Ctrl+letter
keystroke shortcuts for doing common tasks, such as Ctrl+C for
copying an item to the Clipboard and Ctrl+V for pasting an item from the
Clipboard into the worksheet (see the Cheat Sheet online at www.
dummies.com/cheatsheet/excel2013 for a complete list). If you
assign the same keystrokes to the macro you’re building, your macro’s
shortcut keys override and, therefore, disable Excel’s ready-made