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!

Extra Data Series in Graph Legends

Status
Not open for further replies.

bhujanga

Programmer
Oct 18, 2007
181
US
I'm creating a bunch of graphs using a macro. Everything works exactly right except it gives me one extra data series in the legend, so if for example there are 7 real data series with actual names, there is also one called 'series8' in the legend but with no associated data. This is my code for one of the graphs:

ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLine
For i = 1 To TinctureTypes
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i).Name = "='Product Sales'!R" & TinctureStart + i - 1 & "C7"
ActiveChart.SeriesCollection(i).Values = "='Product Sales'!R" & TinctureStart + i - 1 & "C8:R" & TinctureStart + i - 1 & "C" & 7 + NumberOfMonths
ActiveChart.SeriesCollection(1).XValues = "='Product Sales'!R" & TinctureStart + TinctureTypes & "C8:R" & TinctureStart + TinctureTypes & "C" & 7 + NumberOfMonths
Next i
ActiveChart.SetElement (msoElementChartTitleCenteredOverlay)
ActiveChart.ChartTitle.Select
Selection.Caption = "='Product Sales'!R" & TinctureStart & "C5"

The 'TinctureTypes' variable is correct, if I reduce it by one then I lose one of the data series and still get an extra one in just the legend. What should I do to fix this?
Thanks.
 
Sorry, I accidentally posted this in the wrong form, please disregard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top