Microsoft Office Tutorials and References
In Depth Information
Running macros when a workbook is opened
Instead of running a macro manually, or even from a toolbar button or a menu, you can
have Excel run a macro whenever a workbook is opened. The trick of making that happen is
in the name you give the macro. Whenever Excel finds a macro with the name Auto_Open,
it runs the macro when the workbook to which it is attached is opened.
TIP If you have your macro security set to the Disable With Notification level, clicking the
Options button that appears on the Message Bar, selecting the Enable This Content option,
and then clicking OK allows the Auto_Open macro to run.
In this exercise, you’ll create and test a macro that runs whenever someone opens the
workbook to which it is attached.
SET UP You need the RunOnOpen workbook located in the Chapter12 practice file
folder to complete this exercise. Open the workbook, click the Enable Content button
on the Message Bar (if necessary), and then follow the steps.
On the View tab, in the Macros group, click the Macros arrow and then, in the list
that appears, click Record Macro to open the Record Macro dialog box.
In the Macro name box, delete the existing name, and then enter Auto_Open .
Click OK to close the Record Macro dialog box.
Select the cell range B3:C11 .
On the Home tab, in the Font group, click the Bold button twice. The first click of the
Bold button formats all the selected cells in bold; the second click removes the bold
formatting from all the selected cells.