title: VBA - Change chart line colour
body: <p>I've been attempting to get a VBA script that will update chart line colours based on an RGB reference that will change based on a score.</p>
  
  <p>I would also like to understand:</p>
  
  <ol>
  <li>How to exclude some sheets from the update</li>
  <li>How to exclude some series from the update (they always remain grey)</li>
  </ol>
  
  <p>My current script is:</p>
  
  <pre><code>Sub UpdateAllChartLines
  
  Dim sht As Worksheet
  Dim CurrentSheet As Worksheet
  Dim cht As ChartObject
  Dim ser As Series
  
  Application.ScreenUpdating = False
  Application.EnableEvents = False
  
  Set CurrentSheet = ActiveSheet
  Set myRed = Worksheets("TextElements").Range("K6")
  Set myGreen = Worksheets("TextElements").Range("K7")
  Set myBlue = Worksheets("TextElements").Range("K8")
  Set myThickness = Worksheets("TextElements").Range("E37")
  
  For Each sht In ActiveWorkbook.Worksheets
    For Each cht In sht.ChartObjects
      For Each ser In cht.SeriesCollection
          cht.Activate
                  With ActiveChart.SeriesCollection
                  .Format.Line.Visible = msoFalse
                  .Format.Line.Visible = msoTrue
                  .Format.Line.ForeColor.RGB = RGB(myRed, myGreen, myBlue)
                  .Format.Line.Weight = myThickness
                   End With
      Next ser
     Next cht
  Next sht
  
  CurrentSheet.Activate
  Application.EnableEvents = True
  
  End Sub
  </code></pre>
  
  <p>My issue recently has been that I get a debug error at </p>
  
  <pre><code>For Each ser In cht.SeriesCollection
  </code></pre>
  
  <p>As ever any help greatly appreciated.</p>