List of available worksheet event in Excel:
The worksheet is activated. The
Worksheet_Activateprocedure is used for handling this event.
The worksheet is about to be deleted. The
Worksheet_BeforeDeleteprocedure is used for handling this event.
The worksheet is double-clicked. This event occurs before the default double-click action. The
Worksheet_BeforeDoubleClickprocedure is used for handling this event.
The worksheet is right-clicked. This event occurs before the default right-click action. The
Worksheet_BeforeRightClickprocedure is used for handling this event.
The worksheet is calculated or recalculated. The
Worksheet_Calculateprocedure is used for handling this event.
Cells on the worksheet are changed by the user or by an external link. The
Worksheet_Changeprocedure is used for handling this event.
The worksheet is deactivated. The
Worksheet_Deactivate()procedure is used for handling this event.
A hyperlink on the worksheet is clicked. The
Worksheet_FollowHyperlinkprocedure is used for handling this event.
A callout gallery has finished rendering all icons. The
Worksheet_LensGalleryRenderCompleteprocedure is used for handling this event.
A cell or range of cells (that contain formulas) inside a PivotTable are edited or recalculated. The
Worksheet_PivotTableAfterValueChangeprocedure is used for handling this event.
This event fires before changes are applied to a PivotTable. The
Worksheet_PivotTableBeforeAllocateChangesprocedure is used for handling this event.
This event fires before changes are committed against the OLAP data source for a PivotTable. The
Worksheet_PivotTableBeforeCommitChangesprocedure is used for handling this event.
This event fires before changes to a PivotTable are discarded (user chosen to roll back the changes). The
Worksheet_PivotTableBeforeDiscardChangesprocedure is used for handling this event.
A pivot table on the worksheet has changed or has been refreshed. The
Worksheet_PivotTableChangeSyncprocedure is used for handling this event.
A pivot table on the worksheet is updated. The
Worksheet_PivotTableUpdateprocedure is used for handling this event.
The selection on the worksheet is changed. The
Worksheet_SelectionChangeprocedure is used for handling this event.
A query table on the sheet has completed updating data from the internal data model. The
Worksheet_TableUpdateprocedure is used for handling this event.
Writing the Worksheet Event Code
Worksheet event procedures must be entered into the code module for the worksheet. Each worksheet comes with its own built-in module, these code modules have default names like
Sheet3 and so on. To open a code module, right click on its worksheet tab and select
View Code, as shown in following figure:
Immediately after you select
View Code, you are taken directly into the VBE (Visual Basic Editor) where you can start entering the event procedure code.
Immediately above the Code window you'll see two dropdown lists. The first dropdown list says
(General) is called "Object List Box" and the second one says
(Declarations) is called "Procedure List Box". Click the
Object (first dropdown) list and select the
Worksheet. It will write the
Worksheet_SelectionChange event procedure on the coding area. Now all the Event procedures are available on the second dropdown list as shown in following figure:
In next tutorials we'll read about the Worksheet events by writing some examples for each event procedure.