Microsoft Office Tutorials and References
In Depth Information
RUN A MACRO FROM A BUTTON
Back in the Excel worksheet, you need to close the Properties dialog by clicking
the red X in the upper-right corner. You also need to exit Design mode by
clicking the Design Mode icon in the Control Toolbox toolbar. If you are done
adding buttons, hide the Control Toolbox by clicking the red X in the upper-right
In Excel 2007, the process is similar. You use the Button icon at the bottom of
the Insert dropdown. The Design Mode, Properties, and View Code icons are
in the same group on the Developer tab. Microsoft nicely added words so you
can easily identify each icon.
Method 3: From Any Shape, Picture, SmartArt, or Clip Art
To set up a macro to run from any shape, picture, SmartArt, or clip art, add
an AutoShape or clip art to your worksheet. Right-click the object and choose
Assign Macro. You can assign a macro to the shape just as in Method 1 for the
In Excel 2003, use Insert, Picture to access a number of objects. Choose
ClipArt, Picture, or AutoShape. If you are going to use AutoShapes, it is best to
display the Drawing toolbar. You can use the icons on the Drawing toolbar to
change the color, shadow, text, number of dimensions, and so on.
In Excel 2007, use the Insert tab of the ribbon. AutoShapes have been renamed
Shapes. You can also add SmartArt. Right-click the diagram when you are
done and choose Assign Macro.
Method 4: From a Hyperlink
Setting up a macro to run from a hyperlink is tricky but possible. To begin,
add some text to a cell—perhaps Run the Macro!. Then choose Insert,
Hyperlink and make the hyperlink jump to the cell that contains the text. This
basically prevents the hyperlink from going anywhere.
Next, switch to VBA. In the Project Explorer, look for the entry for the worksheet
where the hyperlinks are. Right-click that sheet name and choose View Code,
as shown in Figure 112.
Figure 112. h e code to intercept the hyperlink has to be
on the code pane for the worksheet.