Page 58 - Microsoft Office Excel 2003 Programming Inside Out
P. 58

Microsoft Office Excel 2003 Programming Inside Out

                               5  Type a description for your macro in the Description box.
                               6  Click OK.
                               7  Click Cancel.


                             Assigning a Macro to a Toolbar Button
                             Running a macro from inside the Macros dialog box is the easy “built-in” way to do it, but
                             when you’re moving quickly through a worksheet, the last thing you want to do is dig
                             through the menu system to open a dialog box, remember the name of the macro you want
                             to run, and run it. It’s much simpler to assign the macro to a toolbar button so you can run
                             the macro with a single click of the mouse. You can add a new toolbar button to an existing
                             toolbar, but it usually makes more sense to create a new toolbar to hold the buttons for your
                             macros. If you have your monitor set at a relatively low screen resolution to avoid eyestrain,
                             for example, there won’t be much room on any of the standard toolbars for another button.
                             Also, if you have toolbar buttons for more than one macro, it might be difficult to pick the
                             button out of a crowd on a densely populated toolbar. If you put your macro toolbar buttons
                             on a toolbar clearly labeled as your custom macro toolbar, you’ll have a much easier time
                             finding your macros and remembering which button is which.
                             To create a new toolbar, add a button to it, and assign a macro to the button, follow these steps:
             Chapter 3
                               1	 Click Tools, Customize. Then, if necessary, click the Toolbars tab to display the
                                  Toolbars tab page of the Customize dialog box.
                               2	 Click New. Then, in the Toolbar Name box, type the name of the new toolbar and then
                                  click OK to create the toolbar.








                               3  In the Customize dialog box, click the Commands tab.
                               4  In the Categories list, click Macros.
                               5  Drag the Custom Button command to your new toolbar.
                               6	 On the new toolbar, right-click the button you just added, click Name, type a name for
                                  the button, and press Enter.
                               7  On the Custom Macros toolbar, right-click the new button and click Assign Macro.













                32
             Part 2:  Visual Basic for Applications
   53   54   55   56   57   58   59   60   61   62   63