Selecting a Chart series by name and then formatting

iepritchard

Board Regular
Joined
Jan 9, 2009
Messages
52
Hi All,

I have a chart on a chart sheet ("Chart2"), and the data on a separate sheet ("Sheet3"). I have multiple series plotted on the chart, but I also will plot All the data and name the series "All" (It will also be the last series). For this series I would like to not show the data markers but I do wish to show a trend line for the series. My main problem at the moment is that I can't select the "All" series on which to perform the formatting..?? The code I have at the moment is...

Sub Graph_Format()

Dim serColl As SeriesCollection
Set serColl = Charts(1).SeriesCollection

serColl(Count).Select

With Selection.Border
.Weight = xlHairline
.LineStyle = xlNone
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlAutomatic
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
Selection.Trendlines.Add(Type:=xlLogarithmic, Forward _
:=0, Backward:=0, DisplayEquation:=True, DisplayRSquared:=True).Select
Selection.Trendlines(1).DataLabel.Select
Selection.Left = 442
Selection.Top = 194

End Sub


Any suggestions..??!

Thanks,
Ian
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Is it?

Code:
    Dim ser As Series
    With Charts(1)
        Set ser = .SeriesCollection(.SeriesCollection.Count)
    End With
    ser.Select
 
Upvote 0
Recording I get..

Sheets("Chart2").Select
ActiveChart.SeriesCollection(14).Select
With Selection.Border
.Weight = xlHairline
.LineStyle = xlNone
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlAutomatic
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
ActiveChart.SeriesCollection(14).Trendlines.Add(Type:=xlLogarithmic, Forward _
:=0, Backward:=0, DisplayEquation:=True, DisplayRSquared:=True).Select
End Sub

where series 14 is the last series.
 
Upvote 0
So this should work:

Code:
    Sheets("Chart2").Select
    With ActiveChart
        .SeriesCollection(.SeriesCollection.Count).Select
    End With
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,393
Members
449,081
Latest member
JAMES KECULAH

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