title: Formatting Chart Legends Using With (Syntax)
body: <p>I have a macro which adds and removes (filterseries) set data series of a chart (in its own sheet) by looping through checkboxes in a separate sheet.  When I add and remove them, I want to cycle the legend off then back on so that it resizes itself automatically.</p>
  
  <p>I think this is just a syntax error of how I'm using the with statement.</p>
  
  <p>I have a separate macro which does this for a different purpose, but it loops through chart-sheets and treats them as variables and, for some reason, it works there.</p>
  
  <pre><code>Sub ISurfSeries1Checklist()
  
      Application.ScreenUpdating = False
      Application.EnableEvents = False
  
      Dim i As Integer
      Dim c As Integer
      For i = 1 To 56
          If ActiveWorkbook.Sheets("Range").Cells(3 + i, 12).Value = True Then
          ActiveWorkbook.Charts("I. Surf (1)").FullSeriesCollection(i).IsFiltered = False
  
          Else 'ActiveWorkbook.Sheets("Range").Cells(3 + i, 12) = False Then
  
          ActiveWorkbook.Charts("I. Surf (1)").FullSeriesCollection(i).IsFiltered = True
  
          End If
      Next i
  
      For c = 51 To 56 'ActiveWorkbook.Charts("I. Surf (1)").FullSeriesCollection.Count
  
      ActiveWorkbook.Charts("I. Surf (1)").FullSeriesCollection(c).Format.Line.Visible = msoTrue
      ActiveWorkbook.Charts("I. Surf (1)").FullSeriesCollection(c).Format.Line.ForeColor.RGB = RGB(255, 0, 0)
      ActiveWorkbook.Charts("I. Surf (1)").FullSeriesCollection(c).Format.Line.Transparency = 0
  
      Next c
  
      ActiveWorkbook.Charts("I. Surf (1)").HasLegend = False
      ActiveWorkbook.Charts("I. Surf (1)").HasLegend = True
  
      '***Below is where it stops working.***
      With ActiveWorkbook.Charts("I.Surf (1)").Legend
          .Font.Size = 8
          .Border.Weight = xlHairline
          .Border.Color = RGB(89, 89, 89)
          .Interior.Color = RGB(255, 255, 255)
          .Left = Cht_Sht.PlotArea.InsideLeft - Cht_Sht.Axes(xlValue).Format.Line.Weight
          .Top = Cht_Sht.PlotArea.InsideTop
     End With
  </code></pre>