Option Explicit
Public WithEvents Graph As Chart
Public WithEvents target As Chart
Private Sub target_MouseMove( _
ByVal Button As Long, _
ByVal Shift As Long, _
ByVal x As Long, _
ByVal y As Long _
)
ActiveSheet.ChartObjects(1).Activate
Dim ElemID As Long, Arg1 As Long, Arg2 As Long
Call ActiveChart.GetChartElement(x, y, _
ElemID, _
Arg1, _
Arg2 _
)
Dim xvalue As Double
Dim value As Double
Dim clickedSeriesXValues, clickedSeriesValues As Variant
Select Case ElemID
Case xlSeries
clickedSeriesXValues = ActiveChart.SeriesCollection(Arg1).XValues
clickedSeriesValues = ActiveChart.SeriesCollection(Arg1).Values
xvalue = clickedSeriesXValues(Arg2)
value = clickedSeriesValues(Arg2)
''' xvalue = ActiveChart.SeriesCollection(Arg1).XValues(Arg2)
''' value = ActiveChart.SeriesCollection(Arg1).Values(Arg2)
'Call MsgBox(xvalue & " " & value)
''=============================================================
Dim ColunaY As Range
Set ColunaY = Range("J2:J5")
Dim cel As Range
For Each cel In ColunaY
Dim IVALUE As Long
IVALUE = IVALUE + 1
Dim FirstCelXi As Range
Dim CelX1 As Range
Dim CelY1 As Range
Set FirstCelXi = ActiveSheet.Range("J2")
Set CelX1 = ActiveSheet.Range("J2").Resize(IVALUE, 2)
Next cel
If Len(FirstCelXi.value) = 0 Then
CelX1.value = Array(xvalue, value)
Else
End If
''=================================================================
''=================================================================
Dim XVals As Variant
Dim Vals As Variant
Dim ElementID As Long
'Dim Arg1 As Long
'Dim Arg2 As Long
Static PrevPoint As Long
Static r As Long
Static c As Long
target.GetChartElement x, y, ElementID, Arg1, Arg2
If ElementID = xlSeries Then
If Arg2 <> PrevPoint Then
XVals = target.SeriesCollection(Arg1).XValues
Vals = target.SeriesCollection(Arg1).Values
r = r + 1
Range("N2").Cells(r, c + 1).value = XVals(Arg2)
Range("O2").Cells(r, c + 1).value = Vals(Arg2)
If r = 20 Then
r = 0
c = c + 3
End If
PrevPoint = Arg2
End If
End If
''=================================================================
''=================================================================
Case Else
End Select
End Sub