Workbook events are triggered when certain actions are performed on a workbook, such as opening or closing it, saving it, or changing worksheets. These events can be used to run macros or custom functions whenever a workbook is opened, closed, saved, or changed. For example, you could use a workbook event to automatically save a backup copy of a workbook every time it is saved.
There are two types of workbook events: those that are triggered by an action taken by the user (such as opening or closing the workbook), and those that are triggered by an action taken by Excel (such as calculating a formula). User-initiated events can be handled by using macros or custom functions, while Excel-initiated events can be handled by using Visual Basic for Applications (VBA) code.
The following table lists the user-initiated workbook events:
Event | Description |
---|---|
Workbook_Open | Triggered when the workbook is opened |
Workbook_Activate | Triggered when the workbook becomes the active workbook |
Workbook_Deactivate | Triggered when the workbook is no longer the active workbook |
Workbook_BeforeClose | Triggered when the workbook is about to be closed |
Workbook_AfterSave | Triggered after the workbook is saved |
>
Move beyondExcelGet started with Causal today. Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals. |