I want to change the chart series line settings in a macro

E

EPL

Hello!

I want to change the chart series line settings (i.e. line size, color, no
marker, etc) in a macro. I can do it from the chart formatting, but the
program is changing and adding new data depending on the user selection, so I
don't want the user to be constantly having to change the line settings.

Thanks for your help!
 
J

John Bundy

I have an interactive chart that charts data according to checkboxes, here is
a piece of the code that is executed when they click a box, i think it shows
what you need.
If Sheet1.CheckBox3 = True Then
seriesNum = seriesNum + 1
Sheet1.ChartObjects("Chart 2").Activate

ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(seriesNum).XValues = "=Detail!R" & startRow
& "C2:R" & endRow & "C2"
ActiveChart.SeriesCollection(seriesNum).Values = "=Detail!R" & startRow
& "C13:R" & endRow & "C13"
ActiveChart.SeriesCollection(seriesNum).Name = "=Detail!R" & startRow -
1 & "C13"
ActiveChart.SeriesCollection(seriesNum).Select
With Selection.Border
.ColorIndex = 3
.Weight = xlMedium
.LineStyle = xlContinuous
End With
Selection.ChartType = xlLine
 
E

EPL

John Bundy said:
I have an interactive chart that charts data according to checkboxes, here is
a piece of the code that is executed when they click a box, i think it shows
what you need.
If Sheet1.CheckBox3 = True Then
seriesNum = seriesNum + 1
Sheet1.ChartObjects("Chart 2").Activate

ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(seriesNum).XValues = "=Detail!R" & startRow
& "C2:R" & endRow & "C2"
ActiveChart.SeriesCollection(seriesNum).Values = "=Detail!R" & startRow
& "C13:R" & endRow & "C13"
ActiveChart.SeriesCollection(seriesNum).Name = "=Detail!R" & startRow -
1 & "C13"
ActiveChart.SeriesCollection(seriesNum).Select
With Selection.Border
.ColorIndex = 3
.Weight = xlMedium
.LineStyle = xlContinuous
End With
Selection.ChartType = xlLine

Thanks John! Worked like a dream!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top