Forum Discussion

perkin_warbeck's avatar
perkin_warbeck
Brass Contributor
May 15, 2021

Question about the VBA SeriesCollection method

According to Microsoft, the SeriesCollection method is defined as   expression.SeriesCollection (Index)   where expression is a variable that represents a Chart object and Index is "the name or n...
  • HansVogelaar's avatar
    May 16, 2021

    perkin_warbeck 

    I got the same error, but it worked when I broke the code down into small steps:

     

        Dim wsh As Worksheet
        Dim obj As ChartObject
        Dim cht As Chart
        Dim ser As Series
        Dim seriesName As String
        Set wsh = Worksheets("Sheet1")
        Set obj = wsh.ChartObjects(1)
        Set cht = obj.Chart
        seriesName = "foo"
        Set ser = cht.SeriesCollection(seriesName)
        ser.Format.Line.ForeColor.RGB = RGB(255, 0, 0)

     

    Weird...

Resources