Page 313 - Excel Workbook for Dummies
P. 313
33_798452 ch23.qxp 3/13/06 7:51 PM Page 296
296 Part VII: Macros and Visual Basic for Applications
Try It
Exercise 23-1: Editing a Recorded Macro in the Visual Basic Editor
If Excel is not currently running, launch the program. You will then unhide the
PERSONAL.XLS workbook from Sheet1 of this workbook and open the Company_
Name macro that you saved as part of your Personal Macro Workbook in Exercise
22-2 in Chapter 21 and edit its commands in the Visual Basic Editor:
1. Choose the Window➪Unhide menu command to open the Unhide dialog box.
2. While PERSONAL.XLS is selected in the Unhide Workbook list box, select the OK
button.
Excel opens the PERSONAL.XLS workbook (indicated by the appearance of
its filename on the Excel program window’s title bar) as a seemingly blank
workbook.
3. Press Alt+F8 to open the Macro dialog box.
The Macro dialog box displays the Company_Name and Twelve_Month macros
you created in Exercise 22-2 (among others, if you’ve recorded macros in the
Personal Macro Workbook on your own).
4. Select the Company_Name macro in the list box before you select the Edit
button.
Excel opens the Visual Basic Editor for the Module1 sheet that contains your
Company_Name macro. The Code window containing the actual commands in
this macro appears less than full size to the right of the Project Explorer and
Properties window.
5. Click the Maximize button on the upper-right of the Code window to maximize
this window in the Visual Basic Editor.
In the Code window, note that explanatory comments that are not executed
as part of the macro are prefaced with apostrophes and appear in green text,
whereas all the VBA commands and properties that are executed at the time you
run the macro appear in blue and black text.
6. Position the insertion point after the b in Sub in the first line of code at the very
top of the Code window and then press F1 to open a Visual Basic Help window
with information on the use of the Sub Statement.
Note the first time you try to get online help in the Visual Basic Editor, an alert
dialog box appears, indicating that Help is not installed and asking you if want to
install it by selecting the Yes button.
After that, you can always get context-sensitive help in the Visual Basic Editor by
positioning the insertion point in the command on which you need help and then
pressing the F1 Help key.
7. Replace Arial with Times New Roman in the Name property that is located
immediately under the With Selection.Font statement. Make sure to retain the
closed pair of double quotation marks around the font name, as in
.Name = “Times New Roman”
8. Increase the font size from 12 to 14 points by changing the Size property, as in
.Size = 14
9. Click the View Microsoft Excel button on the Standard toolbar in the Visual Basic
Editor (the very first one with the green XL logo).
Excel closes the Visual Basic Editor window and returns you to the Personal
Macro Workbook, PERSONAL.XLS.