Chapter 19. Understanding Excel’s Events
In This Chapter
This chapter explains the concept of Excel events, and I include many examples that you can adapt to your own needs. As you will see, understanding events can give your Excel applications a powerful edge. Here, you will find:
An overview of the types of events that Excel can monitor
Essential background information for working with events
Examples of
Workbook
events,Worksheet
events,Chart
events, andUserForm
eventsUsing
Application
events to monitor all open workbooksExamples of processing time-based events and keystroke 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. A simple 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.
Excel is capable of monitoring a wide variety of events and executing your VBA code when a particular event occurs. Following are just a few examples of the types of events that Excel recognizes:
A workbook is opened or closed.
A window is activated.
A worksheet is activated or deactivated.
Data is entered into a cell or the cell is edited.
A workbook is about to be saved.
A workbook is about to be printed.
A worksheet is calculated.
An object is clicked.
The data in a chart is updated.
A particular key or key combination is pressed.
A particular time of day occurs.
Event Types ...
Get Excel® 2007 Power Programming with VBA now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.