Jyn

UNDERSTANDING EXCEL EVENTS &-—-

An event occurs within Excel whenever you perform any type of action. For example, if you click a particular cell, a Click event occurs. You can use these events to trigger the execution of particular procedures by creating event-handling procedures. Event-handling procedures are exactly what the name describes, procedures that execute when a particular event occurs.

WORKBOOK EVENTS

You can monitor five different types of events within Excel: workbook, worksheet, chart, UserForm, and application events. To trap or capture an event with an event-handling procedure, you must place the procedure code in the correct type of module. For example, you must place all workbook-related events in the ThisWorkbook object code module.

Excel associates workbook level events with the corresponding workbook where they reside. You need to place the procedures within the ThisWorkbook object module. You create this procedures by naming them Workbook_event name. The following table lists each of the available workbook events.

EVENT

DESCRIPTION

Activate

Excel activates the workbook.

AddinInstall

An add-in installs a workbook.

AddinUninstall

An add-in uninstalls a workbook.

BeforeClose

A workbook closes. See the section "Run a Procedure before Closing a Workbook."

BeforePrint

Excel prints a portion of a workbook.

BeforeSave

Excel saves a workbook. See the section "Run a Procedure before Saving a Workbook."

Deactivate

Excel deactivates a workbook.

NewSheet

Excel adds a new sheet to a workbook.

Open

Excel opens a workbook. See the section "Run a Procedure as a Workbook Opens."

PivotTableCloseConnection

Occurs after a Pivot table report closes the data source connection.

PivotTableOpenConnection

Occurs after a Pivot table report opens the data source connection.

SheetActivate

Excel activates a sheet in the workbook.

SheetBeforeDoubleClick

Occurs before a user double-clicks a sheet.

SheetBeforeRightClick

Occurs before a user clicks with the right mouse button.

SheetCalculate

Excel calculates a sheet.

SheetDeactivate

Excel deactivates a sheet.

SheetFollowHyperlink

A user clicks a hyperlink on a sheet.

SheetPivotTableUpdate

Excel updates a sheet of a Pivot table report.

SheetSelectionChange

The selection changes on a workbook.

WindowActivate

Excel activates a workbook window.

WindowDeactivate

Excel deactivates a workbook window.

WindowResize

Excel resizes a workbook window.

AUTOMATING PROCEDURES WITH EXCEL EVENTS

WORKSHEET EVENTS

Excel associates worksheet-level events with the the code module for the worksheet object. The currently selected worksheet. You need to place following table lists each of the available worksheet event-handling procedures related to a worksheet in events.

EVENT

DESCRIPTION

Activate

Excel activates the worksheet.

BeforeDoubleClick

Occurs before the user double-clicks the worksheet with the mouse.

BeforeRightClick

Occurs before the user clicks the worksheet with the right mouse button.

Calculate

Excel calculates the worksheet.

Change

Occurs when a user or external link modifies cells on the worksheet. See the section "Monitor a Range of Cells for Changes."

Deactivate

Excel deactivates the worksheet.

FollowHyperlink

User selects a Hyperlink on the worksheet.

PivotTableUpdate

Occurs after a Pivot table report is updated on the worksheet.

SelectionChange

Selection changes on the worksheet.

CHART EVENTS

Excel associates Chart level events with the currently the chart object. The following table lists the available selected chart sheet. You need to place event-handling chart events for which you can create event-handling procedures related to a chart in the code module for procedures.

EVENT

DESCRIPTION

Activate

Excel activates the chart sheet.

BeforeDoubleClick

Occurs before the user double-clicks the chart sheet with the mouse.

BeforeRightClick

Occurs before the user clicks the chart sheet with the right mouse button. See the section "Run a Procedure when Right-Clicking a Chart."

Calculate

Occurs after Excel plots the chart.

Deactivate

Excel deactivates the chart sheet.

DragOver

The user drags a range of cells over a chart.

DragPlot

The user drags and drops a range of cells onto the chart.

MouseDown

The user presses a mouse button over the chart.

MouseMove

The position of a mouse changes over a chart.

MouseUp

The user releases a mouse over the chart.

Resize

The user resizes the chart.

Select

The user selects a chart element.

SeriesChange

Occurs when the user changes the value of a chart data point.

0 0

Post a comment