Page 29 - Excel for Scientists and Engineers: Numerical Methods
P. 29
6 EXCEL: NUMERICAL METHODS
To illustrate the use of the Recorder, let's record the action of applying
scientific number formatting to a number in a cell. First, select a cell in a
worksheet and enter a number. Now choose Macro from the Tools menu, then
Record New Macro ... from the submenu. The Record Macro dialog box
(Figure 1-6) will be displayed.
The Record Macro dialog box displays the default name that Excel has
assigned to this macro: Macrol, Macro2, etc. Change the name in the Macro
Name box to ScientificFormat (no spaces are allowed in a name). The "Store
Macro In" box should display This Workbook (the default location); if not,
choose This Workbook. Enter "e" in the box for the shortcut key, then press OK.
Figure 1-6. The Record Macro dialog box.
The Stop Recording toolbar will appear (Figure 1-7), indicating that a macro is
being recorded. If the Stop Recording toolbar doesn't appear, you can always
stop recording by using the Tools menu (in the Macro submenu the Record New
Macro.. . command will be replaced by Stop Recording).
Figure 1-7. The Stop Recording toolbar.
Now choose Cells ... from the Format menu, choose the Number tab and
choose Scientific number format, then press OK. Finally, press the Stop
Recording button.
To examine the macro code that you have just recorded, choose Macro from
the Tools menu and Visual Basic Editor from the submenu. Click on the node
for the module in the active workbook. This will display the code module sheet
containing the Visual Basic code. The macro should look like the example
shown in Figure 1-8.