我在图表中包含了我不打算包含的其他数据系列。它仅出现在第一次迭代中,而没有其他迭代。该系列的值为“ = {1}”。该数据系列如何包含在图表中以及如何删除?
Set sh = Worksheets("LowDistCharts")
Set chrt = sh.ChartObjects.Add(0, 0, 300, 300)
Set ch = chrt.Chart
With chrt
.Height = 300
.Width = 300
.Top = 1 + ((aa - 4) * 300)
.Left = 1
End With
With ch
.HasTitle = True
.ChartTitle.Text = aa & " " & StartDate & " to " & EndDate
.ChartTitle.Font.Size = 8
.ChartType = xlLine
.SeriesCollection.NewSeries
.SeriesCollection(1).Values = ActiveWorkbook.Worksheets("ActiveSheet").Range(RngXR, RngXR2)
'.SeriesCollection(1).AxisGroup = 1
.SeriesCollection.NewSeries
.SeriesCollection(2).Values = ActiveWorkbook.Worksheets("ActiveSheet").Range(RngStartR, RngEndR)
.SeriesCollection(2).AxisGroup = 2
.SeriesCollection(3).Delete
.HasLegend = False
End With
答案 0 :(得分:1)
添加图表时,如果在创建图表时选择了数据单元格,则可能会发现一个或多个“自动添加”系列。
您可以确保在添加所需数据之前将其删除:
Set chrt = sh.ChartObjects.Add(0, 0, 300, 300)
Set ch = chrt.Chart
Do While ch.SeriesCollection.Count > 1
ch.SeriesCollection(1).Delete
Loop