A subroutine can be executed in several ways at runtime, that is, when
the actual end-users are interfacing with your application. Most often
a subroutine is executed from a worksheet or chart sheet by clicking an
object, such as a command button, to which it has been attached or
associated with its Click Event. A subroutine can be run using
a keyboard shortcut. Also, it is common for a subroutine to be run,
or called, from within another procedure. It is further
possible to write special procedures that automatically run at
certain events, such as when the workbook is opened or closed or when
a certain sheet is activated.
At design time you may want to test a your code. To accomplish this
there are some other less elegant but more flexible ways to run a
subroutine, such as executing a procedure call while working in the
debug window. Some procedures can be executed from within a module by
inserting your cursor at the beginning of the procedure then choosing
Run Sub/Userform from the Run menu, by pressing F5
using the keyboard, or by using the Run Macro button on the
Visual Basic toolbar. Finally, it is also possible to execute a
subroutine by choosing Macro from the Tools menu,
selecting the procedure you desire to run, then clicking the Run
button on the Macro dialog.
Something to add?
Let me know.
|