Bonjour,
J'ai modifié un peu le code de C5 afin de supprimer les courbes avant le changement de date > et replacé les x en regard des nouveaux noms ...
J'ai aussi déplacé "afficher/masquer" les courbes dans une macro à part ...
Ça fonctionne, quel que soit le nombre de courbes ...
Ça fonctionne au changement de date ...
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Dlig As Integer, i As Integer, j As Integer
Application.ScreenUpdating = False
Dlig = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("C5", "D7:D" & Dlig)) Is Nothing Then
If Target.Row = 5 And Target.Column = 3 Then
' boucle pour effacer les courbes avant le changement de date
For j = 7 To Dlig
Cells(j, "D").ClearContents
Call AfficherMasquerLaCourbe(j)
Next j
Lastline_Name = Range("B" & Rows.Count).End(xlUp).Row
If Lastline_Name > 6 Then Range(Cells(7, 2), Cells(Lastline_Name, 4)).ClearContents
For i = 4 To 30 Step 2
If Range("C5") = Sheets("Notes").Cells(15, i) Then
lastline_notes = Sheets("Notes").Range("A" & Rows.Count).End(xlUp).Row
For j = 19 To lastline_notes
If Sheets("Notes").Cells(j, i) > 1.5 Then
Lastline_Name = Range("B" & Rows.Count).End(xlUp).Row
Cells(Lastline_Name + 1, "B") = Sheets("Notes").Cells(j, 1)
Cells(Lastline_Name + 1, "C") = Sheets("Notes").Cells(j, i)
' place un x et affiche la courbe
Cells(Lastline_Name + 1, "D") = "x"
Call AfficherMasquerLaCourbe(Lastline_Name + 1)
End If
Next j
End If
Next i
End If
' si l'on supprime ou place un x en D devant un nom
If Target.Row > 6 And Target.Row <= ChartObjects("Evolution").Chart.SeriesCollection.Count + 6 _
Then Call AfficherMasquerLaCourbe(Target.Row)
End If
End Sub
Sub AfficherMasquerLaCourbe(LL As Integer)
Application.ScreenUpdating = False
If Cells(LL, "D") = "x" Then
ChartObjects("Evolution").Chart.SeriesCollection(LL - 6).Format.Line.Visible = True
Else
ChartObjects("Evolution").Chart.SeriesCollection(LL - 6).Format.Line.Visible = False
End If
End Sub
ric