Private Sub CommandButton1_Click()
Dim test As Boolean, t, i&, x As Variant
Application.ScreenUpdating = False
test = CommandButton1.Caption Like "Afficher*"
With ChartObjects(1).Chart
.SetElement IIf(test, msoElementPrimaryCategoryAxisNone, msoElementPrimaryCategoryAxisShow) 'masque/affiche l'axe
.Axes(xlCategory).AxisTitle.Text = IIf(test, " ", "Pk (m)") 'masque/affiche le titre de l'axe
With .SeriesCollection(1)
.HasDataLabels = False 'RAZ
If test Then
t = [B6].CurrentRegion.Resize(, 3) 'B6 à adapter
For i = 2 To UBound(t)
If t(i, 3) = 0 Then
x = Application.VLookup(Round(t(i, 1)), [I6].CurrentRegion, 2, 0) 'RECHERCHEV, I6 à adapter
If Not IsError(x) Then
.Points(i - 1).ApplyDataLabels
.DataLabels(i - 1).Text = x
End If
End If
Next
With .DataLabels
.Position = xlLabelPositionBelow
.Orientation = xlUpward
.Format.TextFrame2.TextRange.Font.Bold = msoTrue 'gras
End With
End If
End With
End With
CommandButton1.Caption = IIf(test, "Masquer", "Afficher") & " les stations"
End Sub