Excel makes it very easy for you to write code that runs when a range of worksheet, chart sheet, and workbook events occur. In previous chapters, we have already seen how to highlight the active row and column of a worksheet by placing code in the Worksheet_SelectionChange event procedure (see Chapter 2). This runs every time the user selects a new range of cells. (You can also find examples demonstrating how to synchronize worksheets in a workbook using the Worksheet_Deactivate and Worksheet_Activate events in Chapter 19.)
It is easy to create workbook, chart sheet, and worksheet events, because Excel automatically provides you with code modules for these objects. However, note that the chart events that are supplied automatically in a chart module apply only to chart sheets, not to embedded charts. If you want to write event procedures for embedded charts, you can do so, but it takes a bit more knowledge and effort.
There are also many other high-level events that can be accessed, for the Application object, for example. These events will be covered later on in Chapters 6 and 14. Events associated with controls and forms will also be treated in the respective chapters. In this chapter we will look, in more detail, at worksheet, chart, and workbook events and related issues.
Event procedures are always associated with a particular object and are contained in the class module that is associated with that object, such as the ThisWorkbook module or the code module ...