Microsoft Office Tutorials and References
In Depth Information
Discovering VBA Charting Tricks
Public WithEvents myChartClass As Chart
Private Sub myChartClass_MouseDown(ByVal Button As Long, _
ByVal Shift As Long, ByVal X As Long, ByVal Y As Long)
Dim IDnum As Long
Dim a As Long, b As Long
‘ The next statement returns values for
‘ IDnum, a, and b
myChartClass.GetChartElement X, Y, IDnum, a, b
‘ Was a series clicked?
If IDnum = xlSeries Then
Select Case b
Case 1
Case 2
Case 3
End Select
End If
End Sub
Clicking the chart generates a MouseDown event, which executes the myChartClass_
MouseDown procedure. This procedure uses the GetChartElement method to determine what
element of the chart was clicked. The GetChartElement method returns information about the
chart element at specified X and Y coordinates (information that is available via the arguments
for the myChartClass_MouseDown procedure).
This workbook, named chart image map.xlsm , is available on the companion
Discovering VBA Charting Tricks
This section contains a few charting tricks that I’ve discovered over the years. Some of these
techniques might be useful in your applications, and others are simply for fun. At the very least,
studying them could give you some new insights into the object model for charts.
Search JabSto ::

Custom Search