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.
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.