VB Charting gives extra Series in Legend

xvexed

New Member
Joined
May 29, 2002
Messages
27
Hello Excelers:

I've been automating some charting with arrays. This bit allows me to create trend charts for X number of series. For some reason this sometimes creates an extra legend entry that contains no data. Has anyone else experience this? or do you see an err in my code? Suggestions welcome.

Thanks,

Sub Charting_TopX()

Dim Brow, SeriesNumber As String

SeriesNumber = Sheets("Charting").Range("A1").Value

With ActiveWorkbook.Charts.Add
End With

For x = 1 To SeriesNumber
Brow = 20 + x

With ActiveChart
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(x).Name = "=Charting!R" & Brow & "C2"
ActiveChart.SeriesCollection(x).Values = "=Charting!R" & Brow & "C3:R" & Brow & "C28"
ActiveChart.SeriesCollection(x).XValues = "=Charting!R19C3:R19C28"
End With
Next x

ActiveChart.ChartType = xlLine

With ActiveChart
.Location Where:=xlLocationAsObject, Name:="Charting"
End With


With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlRight
ActiveChart.HasDataTable = False

With ActiveChart
.Parent.Name = "MyChart"
.HasTitle = False
End With

End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,203,435
Messages
6,055,357
Members
444,781
Latest member
rishivar

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