One of the most useful pairs of macros is
AUTO_OPEN and AUTO_CLOSE
Any macro with the name AUTO_OPEN will execute automatically whenever a worksheet is opened.
This means you can control the activities of the user as soon as your worksheet is loaded.
Similiarly you can name a macro AUTO_CLOSE.
This macro executes automatically whenever your worksheet is closed.
It is good housekeeping to ensure that any changes you make to the way Excel operates in the AUTO_OPEN macro are reversed in the AUTO_CLOSE macro.
Exercise
We will rename our 'Cleanup' macro as Auto_open.
Rename our 'Restore' macro as Auto_close
Save the worksheet and close it.
Reopen the worksheet to see the see the effects of AUTO_OPEN.
Excel should appear as follows:
In this example we simplified Excel appearence for an end user.
A more powerful application is to control how the user runs your application.
By causing AUTO_OPEN to run a series of Dialog Boxes you can force the user to interact with your application in the way you determine, thus reducing the scope for error.
Practice Exercises
You should attempt exercise 13.1, 13.2 and 13.3