Chapter 19: 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 that 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 that occur. These events can be classified as the following:
• 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 ...