title: Recorded macro breaks on Legend formatting
body: <pre><code>Sub Total()
  ActiveChart.ClearToMatchStyle
  ActiveChart.ChartStyle = 227
  ActiveSheet.ChartObjects("Chart 19").Activate
  ActiveChart.Legend.Select
  ActiveChart.Legend.LegendEntries(1).Select
  With Selection.Format.Line
      .Visible = msoTrue
      .ForeColor.ObjectThemeColor = msoThemeColorText1
      .ForeColor.TintAndShade = 0
      .ForeColor.Brightness = 0
      .Transparency = 0
  End With
  ActiveChart.Legend.LegendEntries(5).Select
  With Selection.Format.Line
      .Visible = msoTrue
      .ForeColor.RGB = RGB(255, 255, 0)
      .Transparency = 0
  End With
  ActiveChart.Legend.LegendEntries(6).Select
  With Selection.Format.Line
      .Visible = msoTrue
      .ForeColor.RGB = RGB(0, 176, 80)
      .Transparency = 0
  End With
  End Sub
  </code></pre>
  
  <p>I tried to recreate this macro multiple times to mould it to my need, so I ran it once to test it and it broke once it got to the <code>With Selection.Format.Line</code>, <a href="https://i.stack.imgur.com/X1vOT.png" rel="nofollow noreferrer">giving me this error</a>. Which part of the macro is causing this error?</p>
  
  <p>Edit: Shai Rado posted perfect fix <a href="https://stackoverflow.com/questions/41854123/recorded-macro-breaks-on-legend-formatting/41854491#41854491">Recorded macro breaks on Legend formatting</a></p>