Introduction Event programming is a very powerful tool that you can use within your VBA code to monitor user actions, take appropriate action when a user does something, or monitor the state of the application as it changes.
If you are programming with your own custom classes, you can extend the functionality of these classes by defining and raising your own custom events, broadcasting the event message to any object that is listening for events from your class.
Events and Event Procedures were introduced in Excel97. Events and event procedures are the same for versions 97 through 2007.
A few new events have been added, but the overall structure of the event system is unchanged.
An and always in the code module of the worksheet, whenever the value of any cell on the worksheet is changed by user input or by other VBA code (but not if the change in value is a result of a formula calculation). The events and their procedure declarations are fixed.
You must not alter the name or parameter list of an event procedure. The events are "hard coded" into the object, such as a Worksheet, and may not be changed.
The VBA Editor will automatically insert the correct procedure declaration. (You can, however, create custom events for your own classes. There are many events that are defined in a Worksheet object, the Workbook object, and the Excel Application object itself.
On this page, we will cover Application events in only in general terms, but not in much detail since they require a different coding model.
(See Application Events for a discussion of Application events.) An event is said to be when the action that initiates the event occurs and the application automatically sends a signal to all components connected to event-generating object (e.g, a Worksheet) indicating that the event has occured.An procedure that is executed automatically by Excel when the event is raised.It is important to remember that in addition to user input, events may run as the results of actions taken by other VBA code.There is no direct way to determine whether the cause of the event was user input or VBA code.You should write your events procedures such that this distinction does not matter.Since VBA can cause an event procedure to run, it is possible that your code may end up in a loop.