I have the following vba code, which should go through series 1-30 in chart 1 and format them according to the code. But the code tells me that there's an invalid parameter with the line "With .SeriesCollection(i)". Does anyone know what's going on? I'm at a loss. I thought this should work correctly. Thanks in advance!
Code:
Sub FormatDataPoints()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Dim i As Long
With ActiveSheet.ChartObjects("Chart 1").Chart
For i = 31 To 40
With .SeriesCollection(i)
.MarkerStyle = 2
.MarkerSize = 7
.Format.Fill.ForeColor.RGB = RGB(0, 128, 0)
.Format.Line.Visible = msoFalse
.ApplyDataLabels
With .DataLabels
.ShowSeriesName = True
.ShowValue = False
.Position = Above
.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 128, 0)
End With
End With
Next i
End With
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
End Sub