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 47 48
| Option Explicit
Public WithEvents Graph As Chart
'*** Utilisation des évènements *********
Private Sub Graph_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 MaRech As Range
Dim MaLigne As Long
On Error Resume Next
ActiveChart.GetChartElement x, y, ElementID, Arg1, Arg2
If Arg2 = 0 Then
ActiveChart.Shapes("Rectangle 1").Visible = msoFalse
Else
Select Case Arg1
Case 1
MaLigne = 1
Case 2
Set MaRech = Sheets("Y.S Densité").Range("A1:A100").Find("1ha1400C", LookIn:=xlValues, lookat:=xlPart)
MaLigne = MaRech.Row - 1
Case 3
Set MaRech = Sheets("Y.S Densité").Range("A1:A100").Find("4ha1400C", LookIn:=xlValues, lookat:=xlPart)
MaLigne = MaRech.Row - 1
End Select
With ActiveChart.Shapes("Rectangle 1")
.Visible = msoTrue
.TextFrame.Characters.Text = _
Sheets("Y.S Densité").Cells(MaLigne, 3).Offset(Arg2, -2) & vbCrLf & _
"Porosité" & "=" & Sheets("Y.S Densité").Cells(MaLigne, 3).Offset(Arg2, -1) & vbCrLf & _
"YS" & "=" & Sheets("Y.S Densité").Cells(MaLigne, 3).Offset(Arg2, 0)
.Left = 0
.Top = 0
.Width = "200"
.Height = "50"
End With
End If
End Sub |
Partager