Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing a different line in Excel graph

Status
Not open for further replies.

mellen

Programmer
Nov 11, 2002
7
CA
Currently, I have a line graph with two lines. Line 1 is green and I don't need to change anything. Line 2 is black and I gotta change it to a thin blue line.
How do I get access to it?
I thought I could just change the index of series collection to (2) but it gives me an error.
ActiveChart.SeriesCollection(1).Select

Below is my code for my subroutine.

Sub EAChangeColorGasStorage()
'
' EAChangeColorGasStorage Macro
' November 10, 1999. Change color to pink
'
' Keyboard Shortcut: Ctrl+Shift+E
'
ActiveWindow.Visible = False
Windows("New Storage Graph.xls").Activate
Range("G32").Select
Sheets("New Charts").Select
ActiveSheet.ChartObjects("Chart 5").Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 10
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Shadow = False

With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 10
.Fill.BackColor.SchemeColor = 10
End With

ActiveWindow.Visible = False
Windows("New Storage Graph.xls").Activate
Range("G37").Select
End Sub
 
Your code should work. You don't actually have to select the series - try:

with ActiveChart.SeriesCollection(2).border
.ColorIndex = 10
.Weight = xlThin
.LineStyle = xlContinuous
End With

Where are you getting the error? After selecting the chart, in the immediate window, do some debugging, such as
?activechart.seriescollection.count
to see how many series Excel recognizes on the chart.

Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top