Showing posts with label Chart. Show all posts
Showing posts with label Chart. Show all posts

Chart Events

Chart Activate Event

This event occurs when a workbook, worksheet, chart sheet, or embedded chart is activated.


Chart BeforeDoubleClick Event

This event occurs when a chart element is double-clicked, before the default double-click action.


Chart BeforeRightClick Event

This event occurs when a chart element is right-clicked, before the default right-click action.


Chart Calculate Event

This event occurs after the chart plots new or changed data, for the Chart object.


Chart Deactivate Event

This event occurs when the chart, worksheet, or workbook is deactivated.


Chart MouseDown Event

This event occurs when a mouse button is pressed while the pointer is over a chart.


Chart MouseMove Event

This event occurs when the position of the mouse pointer changes over a chart.


Chart MouseUp Event

This event occurs when a mouse button is released while the pointer is over a chart.


Chart Resize Event

This event occurs when the chart is resized.


Chart Select Event

This event occurs when a chart element is selected.


Chart SeriesChange Event

This event occurs when the user changes the value of a chart data point by clicking a bar in the chart and dragging the top edge up or down thus changing the value of the data point.



Chart BeforeDoubleClick Event



Syntax
Private Sub Chart_BeforeDoubleClick(ByVal ElementID As Long, ByVal Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)
Enter Code
End Sub

This event will run when a chart is double clicked before the default double click action.

Required Parameters
Cancel
When this event occurs this value is set to False. If this parameter is set to True, the default double-click action will not perform when the procedure is finished.

Arg1
Additional event information, depending on the value of ElementID. For more information about this parameter, see the Chart Arguments.

Arg2
Additional event information, depending on the value of ElementID. For more information about this parameter, see the Chart Arguments.

ElementID
The double-clicked object. The value of this parameter determines the expected values of Arg1 and Arg2. For more information about this parameter, see the Chart Arguments.

Example
Private Sub Chart_BeforeDoubleClick(ByVal ElementID As Long, _
ByVal Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)

If ElementID = xlFloor Then
Cancel = True
MsgBox "Chart formatting for this item is restricted."
End If

End Sub

Result
This example overrides the default double-click behavior for the chart floor.

Chart BeforeRightClick Event



Syntax
Private Sub Chart_BeforeRightClick(Cancel As Boolean)
Enter Code
End Sub

This event will run code after user right clicks on this chart but before the default, right click action occurs.

Required Parameters
Cancel
The cancel parameter can be assigned a value of true or false.  Initially the value is set to false. If the cancel parameter is assigned a value of true then the default right click action will not happen.

Example
Private Sub Chart_BeforeRightClick(Cancel As Boolean)
Chart.Visible = xlSheetHidden
Cancel = True
End Sub

Result
The example will hide the chart before it is right clicked and will not continue with the default right click function.

Chart Calculate Event



Syntax
Private Sub Chart_Calculate()
Enter Code
End Sub

This event will run code after the chart plots new or changed data, for the Chart object.

Example
Private Sub Chart_Calculate()
MsgBox Chart.Name & " has been calculated"
End Sub

Result
The example will pop up a message box that notifies the user that this chart has been calculated.