I have a chart with allot of lines. Not all the lines are relevant all the time it depends on the situation.
On the internet i find this.

I changes the name of the chart and the number of the i's. But the macro still not finding the name of the chart. The title of the chart is NTU41 but is this the same as a chart name?


Sub HideShowLine()
  Application.ScreenUpdating = False
  Dim i As Integer
  For i = 1 To 7
    If ActiveSheet.CheckBoxes("Check Box " & i).Value = -4146 Then
      ActiveSheet.ChartObjects("NTU41").Activate
      ActiveChart.SeriesCollection(i).Format.Line.Visible = msoFalse
    Else
      ActiveSheet.ChartObjects("NTU41").Activate
      ActiveChart.SeriesCollection(i).Format.Line.Visible = msoTrue
    End If
  Next i
End Sub

Sub AssignMacro()
  Application.ScreenUpdating = False
  Dim i As Integer
  For i = 1 To 7
    ActiveSheet.Shapes.Range(Array("Check Box " & i)).Select
    Selection.OnAction = "HideShowLine"
  Next i
End Sub