Excel 2019 Bible

(singke) #1

Chapter 42: Introducing Visual Basic for Applications


42


Recording your actions to create VBA code: the basics
The Excel macro recorder translates your actions into VBA code. To start the macro recorder,
choose Developer ➪ Code ➪ Record Macro (or click the Record Macro icon on the left side of
the status bar). The Record Macro dialog box, as shown in Figure 42.7, appears.

FIGURE 42.7
The Record Macro dialog box

The Record Macro dialog box presents several options:

Macro Name The name of the macro. Excel proposes generic names, such as Macro1,
Macro2, and so on.
Shortcut Key You can specify a key combination that executes the macro. The key combi-
nation always uses the Ctrl key. You can also press Shift when you enter a letter. For exam-
ple, pressing Shift while you press H makes the shortcut key combination Ctrl+Shift+H.

Shortcut keys assigned to macros take precedence over built-in shortcut keys. For example, if you assign Ctrl+S to a
macro, you can’t use the key combination to save your workbook when that macro is available.


Store Macro In The location for the macro. Your choices are the current workbook, your
Personal Macro Workbook (see “Storing macros in your Personal Macro Workbook” later in
this chapter), or a new workbook.
Description A description of the macro (optional).

To begin recording your actions, click OK; your actions within Excel are converted to VBA
code. When you finish recording the macro, choose Developer ➪ Code ➪ Stop Recording, or
you can click the Stop Recording button on the status bar. This button replaces the Start
Recording button while your macro is being recorded.
Free download pdf