Worksheet Level

There are 23 different events.
More details on how to add these events can be found here: VBA > Events > Worksheet Level

EventDescription
Activate
Cast (DocEvents_Event)
(Worksheet and Chart sheet) Occurs when this worksheet is selected. This should be used instead of the OnSheetActivate property.
BeforeDeleteOccurs before the worksheet is deleted.
BeforeDoubleClickOccurs before any cell on this worksheet is double clicked. This should be used instead of the OnDoubleClick property.
BeforeRightClickOccurs before any cell is right mouse clicked.
Calculate
Cast (DocEvents_Event)
Occurs before any cell on this worksheet is re-calculated. This event will also capture table filter changes as long as the table has a Total Row enabled. This should be used instead of the OnCalculate property.
Change(Worksheet and Chart sheet) Occurs when any cell on this worksheet is changed either by the user or by an external link. This event is not fired if the value changes as the result of a calculation. This should be used instead of the OnEntry property.
Passes a Range as a parameter for the range of cells that was changed.
Deactivate(Worksheet and Chart sheet) Occurs when the user moves focus to another worksheet. This event does not fire when the user moves between two windows displaying the same worksheet.
FollowHyperLink(Worksheet only) Occurs when you click any hyperlink on a worksheet.
LensGalleryRenderCompleteOccurs when a callout gallery's icons have completely rendered (dynamic and static)
MouseDown(Chart sheet only) Occurs when a mouse button is pressed while the pointer is over an embedded chart or chart sheet
MouseMove(Chart sheet only) Occurs when the mouse pointer is moved over the chart
MouseUp(Chart sheet only) Occurs when a mouse button is released while the pointer is over an embedded chart or chart sheet
PivotTableAfterValueChangesOccurs after a cell or range of cells inside a pivot table are edited or recalculated (when cells contain formulas).
PivotTableBeforeAllocateChangesOccurs before changes are applied to a pivot table.
PivotTableBeforeCommitChangesOccurs before changes are committed against the OLAP data source for a pivot table.
PivotTableBeforeDiscardChangesOccurs before changes to a pivot table are discarded.
PivotTableChangeSyncOccurs after changes to a pivot table.
PivotTableUpdate(Worksheet only) Occurs after a pivot table report is updated on a worksheet.
Resize(Chart sheet only) Occurs when a chart is resized
SelectEvent(Chart sheet only) Occurs when a chart element is selected
SelectionChange(Worksheet only) Occurs when the selection is changed on the worksheet.
SeriesChange(Chart sheet only) Occurs when a value of a chart data point changes.
TableUpdateOccurs after a query table connected to the Data Model is updated on a worksheet.

Worksheet_Activate

Private Sub Worksheet_Activate() 
End Sub
public void WshEvents_Activate()
{
    if (mbFireEvents == true)
        WshEventsActivate_Event?.Invoke();
}
Public Sub WshEvents_Activate() Handles WshEvents2.Activate

   If (mbFireEvents = True) Then
      RaiseEvent WshEventsActivate_Event()
   End If
End Sub

Worksheet_BeforeDelete

Private Sub Worksheet_BeforeDelete() 
End Sub

Worksheet_BeforeDoubleClick

Private Sub Worksheet_BeforeDoubleClick( _ 
         ByVal Target As Range, _
         ByRef Cancel As Boolean)
End Sub
public void WshEvents_BeforeDoubleClick(
  Excel.Range Target,
  ref bool Cancel)
{
    if (mbFireEvents == true)
        WshEventsBeforeDoubleClick_Event?.Invoke(Target, Cancel);
}
Public Sub WshEvents_BeforeDoubleClick(ByVal Target As Excel.Range, _
                                       ByRef Cancel As Boolean) _
                                       Handles WshEvents.BeforeDoubleClick

   If (mbFireEvents = True) Then
      RaiseEvent WshEventsBeforeDoubleClick_Event(Target, Cancel)
   End If
End Sub

Worksheet_BeforeRightClick

This example shows you how to add an item to the cell shortcut menu for all the cells in the range "A1:G200".

Private Sub Worksheet_BeforeRightClick( _ 
         ByVal Target As Range, _
         ByRef Cancel As Boolean)
   For Each ctlcontrol In Application.CommandBars("cell").Controls
      If ctlcontrol.Tag = "added" Then ctlcontrol.Delete
   Next ctlcontrol
   If Not Application.Intersect(Target, Range("A1:G200")) Is Nothing Then
      With Application.CommandBars("cell").Controls.Add( _
               Type:=msoCommandButton, before:=6, temporary:=True)
         .OnAction = "MySubroutine"
         .Tag = "added"
      End With
   End If
End Sub
public void WshEvents_BeforeRightClick(
  Excel.Range Target,
  ref bool Cancel)
{
    if (mbFireEvents == true)
        WshEventsBeforeRightClick_Event?.Invoke(Target, Cancel);
}

Public Sub WshEvents_BeforeRightClick(ByVal Target As Excel.Range, _
                                      ByRef Cancel As Boolean) _
                                      Handles WshEvents.BeforeRightClick

   If (mbFireEvents = True) Then
      RaiseEvent WshEventsBeforeRightClick_Event(Target, Cancel)
   End If
End Sub

Worksheet_Calculate

Private Sub Worksheet_Calculate() 
End Sub
private void WshEvents_Calculate()
{
    if (mbFireEvents == true)
        WshEventsCalculate_Event?.Invoke();
}
Private Sub WshEvents_Calculate() Handles WshEvents2.Calculate

   If (mbFireEvents = True) Then
      RaiseEvent WshEventsCalculate_Event()
   End If
End Sub

Worksheet_Change

Private Sub Worksheet_Change( _ 
         ByVal Target As Range)
End Sub
public void WshEvents_Change(
  Excel.Range Target)
{
    if (mbFireEvents == true)
        WshEventsChange_Event?.Invoke(Target);
}
Public Sub WshEvents_Change(ByVal Target As Excel.Range) _
                            Handles WshEvents.Change

   If (mbFireEvents = True) Then
      RaiseEvent WshEventsChange_Event(Target)
   End If
End Sub

Worksheet_Deactivate

Private Sub Worksheet_Deactivate() 
End Sub
public void WshEvents_Deactivate()
{
    if (mbFireEvents == true)
        WshEventsDeactivate_Event?.Invoke();
}
Public Sub WshEvents_Deactivate() Handles WshEvents.Deactivate

   If (mbFireEvents = True) Then
      RaiseEvent WshEventsDeactivate_Event()
   End If
End Sub

Worksheet_FollowHyperlink

Private Sub Worksheet_FollowHyperlink( _ 
         ByVal Target As Hyperlink)
End Sub
public void WshEvents_FollowHyperlink(
  Excel.Hyperlink Target)
{
    if (mbFireEvents == true)
        WshEventsFollowHyperlink_Event?.Invoke(Target);
}
Public Sub WshEvents_FollowHyperlink(ByVal Target As Excel.Hyperlink) _
                                     Handles WshEvents.FollowHyperlink

   If (mbFireEvents = True) Then
      RaiseEvent WshEventsFollowHyperlink_Event(Target)
   End If
End Sub

Worksheet_LensGalleryRenderComplete

Private Sub Worksheet_LensGalleryRenderComplete() 
End Sub

Worksheet_PivotTableAfterValueChange

Private Sub Worksheet_PivotTableAfterValueChange( _ 
         ByVal TargetPivotTable As PivotTable, _
         ByVal TargetRange As Range)
End Sub

Worksheet_PivotTableBeforeAllocateChanges

Private Sub Worksheet_PivotTableBeforeAllocateChanges( _ 
         ByVal TargetPivotTable As PivotTable, _
         ByVal ValueChangeStart As Long, _
         ByVal ValueChangeEnd As Long, _
         ByRef Cancel As Boolean)
End Sub

Worksheet_PivotTableBeforeCommitChanges

Private Sub Worksheet_PivotTableBeforeCommitChanges( _ 
         ByVal TargetPivotTable As PivotTable, _
         ByVal ValueChangeStart As Long, _
         ByVal ValueChangeEnd As Long, _
         ByRef Cancel As Boolean)
End Sub

Worksheet_PivotTableBeforeDiscardChanges

Private Sub Worksheet_PivotTableBeforeDiscardChanges( _ 
          ByVal TargetPivotTable As PivotTable, _
          ByVal ValueChangeStart As Long, _
          ByVal ValueChangeEnd As Long)
End Sub

Worksheet_PivotTableChangeSync

Private Sub Worksheet_PivotTableChangeSync( _ 
         ByVal Target As PivotTable)
End Sub

Worksheet_PivotTableUpdate

Private Sub Worksheet_PivotTableUpdate( _ 
         ByVal Target As PivotTable)
End Sub
public void WshEvents_PivotTableUpdate(
  Excel.PivotTable Target)
{
    if (mbFireEvents == true)
        WshEventsPivotTableUpdate_Event?.Invoke(Target);
}
Public Sub WshEvents_PivotTableUpdate(ByVal Target As Excel.PivotTable) _
                                      Handles WshEvents.PivotTableUpdate

   If (mbFireEvents = True) Then
      RaiseEvent WshEventsPivotTableUpdate_Event(Target)
   End If
End Sub

Worksheet_SelectionChange

Private Sub Worksheet_SelectionChange( _ 
         ByVal Target As Range)
End Sub
public void WshEvents_SelectionChange(Excel.Range Target)
{
    if (mbFireEvents == true)
        WshEventsSelectionChange_Event?.Invoke(Target);
}
Public Sub WshEvents_SelectionChange(ByVal Target As Excel.Range) _
                                     Handles WshEvents.SelectionChange

   If (mbFireEvents = True) Then
      RaiseEvent WshEventsSelectionChange_Event(Target)
   End If
End Sub

Worksheet_TableUpdate

Private Sub Worksheet_TableUpdate( _ 
         ByVal Target As TableObject)
End Sub

© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext