Microsoft Office Tutorials and References
In Depth Information
Figure 16-20: A text box displays information about the data point under the mouse pointer.
The event procedure that follows is located in the code module for the Chart sheet
that contains the chart.
Private Sub Chart_MouseMove(ByVal Button As Long, ByVal Shift As Long, _
ByVal X As Long, ByVal Y As Long)
Dim ElementID As Long
Dim arg1 As Long, arg2 As Long
Dim NewText As String
On Error Resume Next
ActiveChart.GetChartElement X, Y, ElementID, arg1, arg2
If ElementId = xlSeries Then
NewText = Sheets(“Sheet1”).Range(“Comments”).Offset(arg2, arg1)
NewText = “”
ActiveChart.Shapes(1).Visible = False
End If
If NewText <> ActiveChart.Shapes(1).TextFrame.Text Then
ActiveChart.Shapes(1).TextFrame.Text = NewText
ActiveChart.Shapes(1).Visible = True
End If
End Sub
This procedure monitors all mouse movements on the Chart sheet. The mouse
coordinates are contained in the X and Y variables, which are passed to the
procedure. The Button and Shift arguments are not used in this procedure.
Search JabSto ::

Custom Search