title: Getting error in naming series collection in a chart in VBA Excel
body: <p>I am having some problem in Excel VBA. When I try to run the below code; it says:</p>
  
  <pre><code>Error 1004:Unable to get the name property of the series class!
  </code></pre>
  
  <p>This error happens at this line of code : (product is defined earlier as string Zyvox and others)</p>
  
  <pre><code>If namec.Name = product Then
  </code></pre>
  
  <p>What should I do? I have tried other things too like </p>
  
  <pre><code>   ActiveChart.SeriesCollection(p).name = product
  </code></pre>
  
  <p>But to no avail! Please help!</p>
  
  <pre><code>Public Sub chartBlue()
  
  Dim i As Integer, j As Integer, p As Integer, namec As Series
  
  
  For i = 4 To Sheets.Count
      Sheets(i).Activate
      For j = 1 To Sheets(i).ChartObjects.Count
          Sheets(i).ChartObjects(j).Activate
          ActiveChart.ChartArea.Select
  
  
          For p = 1 To ActiveChart.SeriesCollection.Count
          Set namec = ActiveChart.SeriesCollection(p)
  
  
              If namec.Name = product Then
                 namec.Border.ColorIndex = 5
  
              End If
  
          Next p
      Next j
    '  Windows(Reportname).Activate
      Sheets(i).Range("A1").Activate
  Next i
  
  End Sub
  </code></pre>