title: Excel VBA - Graph Update Loop
body: <p>Having trouble with the below code I've written. It should be updating the entries of a graph that previously ran from DL5:HX5 to DL5:IU5, have around 100 sheets hence the loop. For some reason it's stepping through but I appear to have a semantic error. Was hoping somebody might shed some light as to what that was. </p>
  
  <p>There are three figures, and I'm not sure this is the best way to access figures on multiple sheets (they're identical copies of one another, with different data.) The first two just extends the time series the additional columns (e.g. HX to IU), the last figure simply color formats a line to a different color (the line is split by projected and actual line fragments.)</p>
  
  <pre><code>Dim i As Integer
  
  For i = 31 To ActiveWorkbook.Worksheets.Count
  
  On Error Resume Next
  
  Worksheets(i).ChartObjects("Chart 2").Activate
  ActiveChart.SeriesCollection(1).Values = "='" &amp; Worksheets(i).Name &amp; "'!$DL$5:$IU$5"
  ActiveChart.SeriesCollection(1).XValues = "='" &amp; Worksheets(i).Name &amp; "'!$DL$3:$IU$3"
  
  Worksheets(i).ChartObjects("Chart 6").Activate
  ActiveChart.SeriesCollection(1).Values = "='" &amp; Worksheets(i).Name &amp; "'!$DL$14:$IU$14"
  ActiveChart.SeriesCollection(2).Values = "='" &amp; Worksheets(i).Name &amp; "'!$DL$15:$IU$15"
  ActiveChart.SeriesCollection(3).Values = "='" &amp; Worksheets(i).Name &amp; "'!$DL$16:$IU$16"
  ActiveChart.SeriesCollection(3).XValues = "='" &amp; Worksheets(i).Name &amp; "'!$DL$3:$IU$3"
  
  Worksheets(i).ChartObjects("Chart 1").Activate
  ActiveChart.SeriesCollection(1).Points(30).Border.Color = RGB(69, 114, 167)
  ActiveChart.SeriesCollection(1).Points(30).Format.Line.ForeColor.RGB = RGB(69, 114, 167)
  
  Next i
  </code></pre>