【发布时间】:2017-07-28 06:31:26
【问题描述】:
我今天尝试使用 VBA 创建动态图表。代码本身运行良好,但我遇到的问题是线图仅显示 21 个数据系列中的 10 个。代码本身通过 .NewSeries 添加了 21 个数据系列,但是当代码完成后,图表仅显示其中的 10 个。有人知道为什么会发生这种情况或对我的问题有解决方案吗?
ActiveSheet.Shapes.AddChart2(, xlLine, 0, 0, 1400).Select
Dim cht As Chart
Set cht = ActiveChart
cht.HasLegend = True
cht.ChartTitle.Text = "Test"
With ActiveChart
Do Until .SeriesCollection.Count = 0
.SeriesCollection(1).Delete
Loop
End With
For i = 2 To clmns Step 4
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(cnt).Name = Worksheets(1).Cells(1, i)
ActiveChart.FullSeriesCollection(cnt).Values = Worksheets(1).Range(Worksheets(1).Cells(1, i), Worksheets(1).Cells(rws, i))
cnt = cnt + 1
Next
问候 本杰明
【问题讨论】:
-
您好,欢迎来到 SO。我们需要您的代码来帮助您,看看出了什么问题。
-
我刚刚发布了代码,clmns在大多数情况下在85左右,rws在2300左右