XY Scatterplot Chart Macro

ttbuson

Board Regular
Joined
Nov 18, 2011
Messages
80
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
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
I have the following vba code, which should go through series 1-30 in chart 1 and format them according to the code.

Code:
...
 
        For i = 31 To 40
            With .SeriesCollection(i)

Hi

You say the code shoud go through series 1-30, but is goes through series 31-40. Is that ok? How many series has the chart?
 
Upvote 0
I get that error in 2010 when the counter value (ie i) is outside the range of the index of the series collection
 
Upvote 0
@pgc01, yeah, that's a typo in my original post. The macro should go through series 31 through 40.

@Firefly2012, that makes a lot of sense. I think what's happening is that I'm trying to run the macro with the rows hidden and it's not working because in 2010 the series are not counted when the rows containing the data are hidden. Does that seem like it makes sense to you?
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top