Excel 2019

Chart Activate, Deactivate, Resize and Calculate Events

In this tutorial, you’ll learn how to use Chart_Activate, Chart_Deactivate, Chart_Resize and Chart_Calculate event procedures. These procedures must be entered into the code module for the Chart object. Each chart sheet comes with its own built-in module, to open a code module, right-click on the chart sheet tab and select View Code, see Figure:

After you select View Code, you are taken directly into the VBE (Visual Basic Editor) where you can start entering the event procedure code:

Chart_Activate

Syntax: Chart_Activate()

The Chart_Activate event procedure runs when a chart sheet is activated or changed.

Chart Activate Event Example:

Private Sub Chart_Activate()
 MsgBox "The chart is activated"
End Sub

Chart_Deactivate

Syntax: Chart_Deactivate()

The Chart_Deactivate event procedure runs when a chart sheet is deactivated. For example when you open another sheet.

Chart Deactivate Event Example:

Private Sub Chart_Deactivate()
 MsgBox "Chart Deactivated"
End Sub

Chart_Calculate

Syntax: Chart_Calculate()

The Chart_Calculate event procedure runs when a new or changed data is plotted on a chart.

Chart Calculate Event Example:

Private Sub Chart_Calculate()
 MsgBox "Chart re-calculated"
End Sub

Chart_Resize

Syntax: Chart_Resize()

The Chart_Resize event procedure runs when you resize a chart using the resize handles.

Chart Resize Event Example:

Private Sub Chart_Resize()
 MsgBox "Chart resized"
End Sub

Chart_SeriesChange

Syntax: Chart_SeriesChange(SeriesIndex, PointIndex)

Note: This event does not work in Excel 2007 and later.

The Chart_SeriesChange event procedure runs when a chart data point is changed. This procedure has two arguments:

  • SeriesIndex
    The offset in the Series collection of updated series
  • PointIndex
    The offset in the Point collection of updated points

Chart SeriesChange Event Example:

Private Sub Chart_SeriesChange(ByVal SeriesIndex As Long, ByVal PointIndex As Long)
 'Not works in Excel 2007 and later.
End Sub
Advertisement:
Advertisement: