
This event is executed when the workbook opens. Open is one of the most important workbook events. You will find the changes working under the scene. Travel from one worksheet to another, save the workbook, create a new sheet and close the workbook.
Excel vba on sheet deactivate code#
Workbook_Open, Workbook_SheetActivate, Workbook_NewSheet, and Workbook_BeforeSave procedures have been included in the ThisWorkbook code module. If you wrongly put them into any other code module, they won’t work. Remember, workbook-related event-handler procedures(VBA codes) must be located in the code module for the ThisWorkbook object. When any window of the workbook is activated.Ĭaution: In the following paragraphs, I shall present some important Workbook-related events that you will use from time to time. The selection on any worksheet is changed. When any worksheet in the workbook is deactivated. When any worksheet is changed by the user. This event executes before the default right-click action. Just before any worksheet is right-clicked. This event executes before the default double-click action. Just before a worksheet in the workbook is double-clicked.

When any sheet in the workbook is activated. When a new sheet is created in the workbook, this event executes.

When the workbook is deactivated, this event executes.

Just before the workbook is saved, this event executes. Just before printing any content of the workbook, this event executes. When the workbook is closed, just before closing this event executes. When the workbook is activated, this event executes.Īfter the workbook is saved, this event executes.
