ijourneaux
New Member
- Joined
- Jul 9, 2018
- Messages
- 38
I have an Excel bar chart I would like to make the chart axis labels hyperlink to other other charts that contain additional details about the specific tag of interest. Is this possible?
Private Sub Chart_MouseUp(ByVal Button As Long, ByVal Shift As Long, _ ByVal x As Long, ByVal y As Long)
Dim ElementID As Long, Arg1 As Long, Arg2 As Long
Dim myX As Variant, myY As Double
Dim FriendlyTagName As String
Dim FirstRow As Long
Dim LastRow As Long
Dim RowValue As Long
Dim Tag As String
Dim TagUnits As String
With ActiveChart
' Pass x & y, return ElementID and Args
.GetChartElement x, y, ElementID, Arg1, Arg2
' Did we click over a point or data label?
If ElementID = xlSeries Or ElementID = xlDataLabel Then
If Arg2 > 0 Then
' Extract x value from array of x values
myX = WorksheetFunction.index _
(.SeriesCollection(Arg1).XValues, Arg2)
' Extract y value from array of y values
myY = WorksheetFunction.index _
(.SeriesCollection(Arg1).Values, Arg2)
' Display message box with point information
' MsgBox "Series " & Arg1 & vbCrLf _
' & """" & .SeriesCollection(Arg1).Name & """" & vbCrLf _
' & "Point " & Arg2 & vbCrLf _
' & "X = " & myX & vbCrLf _
' & "Y = " & myY
End If
bFollowHyperlink = True
sSourceChart = "TornadoChart"
FriendlyTagName = Left(myX, InStr(myX, "(") - 2)
FirstRow = 2
LastRow = Worksheets("TagGroups").Range("A65536").End(xlUp).row
RowValue = Application.Match(FriendlyTagName, Worksheets("TagGroups").Range("c1:c501"), 0)
Tag = Worksheets("TagGroups").Cells(RowValue, 2)
TagFriendlyName = Worksheets("TagGroups").Cells(RowValue, 3)
TagUnits = Worksheets("TagGroups").Cells(RowValue, 13)
Application.ScreenUpdating = False
Worksheets("Trend").Activate
Worksheets("Trend").Cells(1, 1) = Tag
Worksheets("Trend").Cells(1, 3) = sServerName
Worksheets("Trend").Cells(1, 4) = "*"
Worksheets("Trend").Cells(2, 1) = TagFriendlyName
Worksheets("Trend").Cells(3, 1) = TagUnits
Worksheets("Trend").Range("G44").Select
Worksheets("Trend").Button1Day_Click
Application.ScreenUpdating = True
End If
End With
End Sub
I agree but I am definitely clicking on the bar in the chart.Element 19 is the plot area. This means you didn't click on any specific point of any specific series. If you click on a point, Arg1 is the series index and Arg2 is the point index.