作者:用户0a8xoj91q0 | 来源:互联网 | 2023-05-21 18:35
我正在尝试更改excel图表中数据点的颜色,但所有尝试都未成功。
这是我尝试的一种方法,但是这些点仍然显示为蓝色:
With Chrt
.ChartType = xlXYScatter
Do Until .SeriesCollection.Count = 0
.SeriesCollection(1).Delete
Loop
.SeriesCollection.NewSeries
.SeriesCollection(1).Name = "=""Top Platen"""
.SeriesCollection(1).Values = yaxis
.SeriesCollection(1).XValues = xaxis
ActiveChart.SeriesCollection(1).Select
With Selection.Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
.Solid
End With
这是我尝试过的另一种方法,但数据点仍显示为蓝色:
With Chrt
.ChartType = xlXYScatter
Do Until .SeriesCollection.Count = 0
.SeriesCollection(1).Delete
Loop
.SeriesCollection.NewSeries
.SeriesCollection(1).Name = "=""Top Platen"""
.SeriesCollection(1).Values = yaxis
.SeriesCollection(1).XValues = xaxis
.SeriesCollection(1).Interior.Color = RGB(255,0,0)
这只是我的代码的一部分,如有必要,我可以提供其他区域。任何帮助将不胜感激。
1> Portland Run..:
我相信问题在于嵌套With
块变得混乱。这是解决它并仍然使用嵌套With
块的一种方法:
With Chrt
.ChartType = xlXYScatter
Do Until .SeriesCollection.Count = 0
.SeriesCollection(1).Delete
Loop
.SeriesCollection.NewSeries
With .SeriesCollection(1)
.Name = "=""Top Platen"""
.Values = yaxis
.XValues = xaxis
.Format.Fill.ForeColor.RGB = RGB(255, 0, 0)
End With
End With
这是Microsoft的文档链接,其中讨论了完全限定的嵌套With
块。