'The following code goes in a Class module sheet named chtClass. You must set the name of the chart module in Properties pane.
Public WithEvents cht As Chart
Private Sub cht_MouseDown(ByVal Button As Long, ByVal Shift As Long, _
ByVal x As Long, ByVal y As Long)
PointClick x, y
End Sub
Private Sub PointClick(ByVal x As Long, ByVal y As Long)
Dim ElementID As Long
Dim Arg1 As Long
Dim Arg2 As Long
cht.GetChartElement x, y, ElementID, Arg1, Arg2
If ElementID = xlSeries Then
Select Case Arg2 'Arg1 is series index, Arg2 is point index
Case 1
Sheets("Chart1").Activate
Case 2
Sheets("Chart2").Activate
Case 3
Sheets("Chart3").Activate
End Select
End If
End Sub
'The following code goes on a regular module sheet
Global oCht As New chtClass
Sub ActivateChart1Events()
Set oCht.cht = Worksheets("Sheet1").ChartObjects(1).Chart
End Sub
Sub DeactivateChart()
Set oCht.cht = Nothing
End Sub
'The following sub goes in ThisWorkbook code pane
Sub Workbook_Open()
ActivateChart1Events
End Sub
|