Question : Can a link a data point in an excel chart to another chart

I have a chart, and i want to link a each single data point on that chart to bring up another chart, is this possible?

Answer : Can a link a data point in an excel chart to another chart

You can create events for clicking a point on a chart by using a class module.

The sample workbook has a class module named chtClass with a MouseDown event sub. By using the GetChartElementID method, we can determine which point was clicked. A Select Case block can then link to a supporting chart.

From past experience, getting class modules set up properly can be a little tricky. I always forget to set the class name in the Properties pane in the VBA Editor, for example.

Brad
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
'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
Random Solutions  
 
programming4us programming4us