Page 52 - Excel Progamming Weekend Crash Course
P. 52

d540629 ch02.qxd  9/2/03  9:27 AM  Page 27




                  Session 2 — The VBA Code Editor                                         27

                          VBA and the Excel object model often provide more than one way to perform
                          a task. Just because a recorded macro codes a task in a certain way does not
                  Note    mean you have to do it exactly that way in your programs.


               Viewing and Running Macros
               To run a macro, you can press the associated hot key if one was assigned to the macro. You
               can also select Tools ➪ Macro ➪ Macros, or press Alt+F8 to display the Macro dialog box (see
               Figure 2-7).


















                    Figure 2-7 You can select a macro to run in the Macro dialog box.
                  This dialog box enables you to run a macro as well as perform other actions. Select the
               desired macro and then:

                   Use the Macros In list to select which macros will be displayed in the list.
                   Click Run to run the selected macro.
                   Click Step Into to debug the macro (see Session 25 for more information on
                   debugging).
                   Click Edit to open the macro in the VBA Editor for viewing and editing.
                   Click Delete to delete the macro.
                   Click Options to change the shortcut key assigned to the macro and/or change the
                   macro description.

                  If you select the Edit option, you can copy code from the macro and then paste it into
               your own programs.


               Online Help
               The VBA Editor provides an excellent online help system that contains detailed information
               about the VBA language, the Excel object model, and the Editor itself. There are several
               ways to access this information.
                  One method is context-sensitive help, accessed by pressing F1. The Editor keeps track of
               what you are doing, and when you press F1, it displays help information that is relevant to
               the task at hand. For example, if you have selected an item in the Project Explorer, pressing
   47   48   49   50   51   52   53   54   55   56   57