Chapter 17: Understanding Excel's Events
In This Chapter
• Recognizing the types of events that Excel can monitor
• Figuring out what you need to know to work with events
• Exploring examples of Workbook events, Worksheet events, Chart events, and UserForm events
• Using Application events to monitor all open workbooks
• Seeing examples of processing time-based events and keystroke events
What You Should Know about Events
In several earlier chapters in this book, I present examples of VBA event-handler procedures, which are specially named procedures that are executed when a specific event occurs. An example is the CommandButton1_Click procedure, which is executed when the user clicks an object named CommandButton1 stored on a UserForm or on a worksheet. Clicking the button is an event that triggers the execution of the event-handler VBA code.
Excel is programmed to monitor many different events. These events can be classified as
• Workbook events: Events that occur for a particular workbook. Examples of such events include Open (the workbook is opened or created), BeforeSave (the workbook is about to be saved), and NewSheet (a new sheet is added).
• Worksheet events: Events that occur for a particular worksheet. Examples include Change (a cell on the sheet is changed), SelectionChange (the user moves the cell indicator), and Calculate (the worksheet is recalculated).
• Chart events: Events that occur for a particular chart. These events include Select (an object in the chart ...