VBA SeriesCollection resets premade template's data series format

pltom55

New Member
Joined
Oct 6, 2014
Messages
27
I have a premade chart (template) with very thin markers to make the data more aesthetic.
I'm trying to import data into my premade chart but only the first data series holds on to the thin markers. All the others are set to default. Code is attached.

I suspect that SetSourceData is setting the data which is why the first data series works as intended, but SeriesCollection(2) is overwriting my (premade) series 2. Has anyone ran into something like this?
Thanks in advance,
Tom


Code:
Sub Silver()
Dim n As Integer
Sheets(3).Activate
Range("D1").Formula = "=count(B:B)"
Range("I1").Formula = "=count(G:G)"
Range("N1").Formula = "=count(L:L)"

n = Range("D1").Value
 

   
    ActiveSheet.Shapes.AddChart2(240, xlXYScatterLines).Select   'Add Chart
    ActiveChart.ApplyChartTemplate ("C:\Users\tweglarz\AppData\Roaming\Microsoft\Templates\Charts\Reflections Chart.crtx")
    ActiveChart.SetSourceData Source:=Range("B6:B" & n, "C6:C" & n)
    
n = Range("I1").Value
        
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(2).XValues = Range("g6:g" & n)   ' Source X data
    ActiveChart.SeriesCollection(2).Values = Range("h6:h" & n)
    
n = Range("N1").Value
        
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(3).XValues = Range("l6:l" & n)  ' Source Y data
    ActiveChart.SeriesCollection(3).Values = Range("m6:m" & n)
   

    
    
End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,215,425
Messages
6,124,824
Members
449,190
Latest member
rscraig11

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