Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 在excel XY散点图中更改数据系列的颜色_Vba_Excel_Graph - Fatal编程技术网

Vba 在excel XY散点图中更改数据系列的颜色

Vba 在excel XY散点图中更改数据系列的颜色,vba,excel,graph,Vba,Excel,Graph,我正在尝试更改excel图表中数据点的颜色,但所有操作都失败了 这是我尝试过的一种方法,但点仍然显示为蓝色: With Chrt .ChartType = xlXYScatter Do Until .SeriesCollection.Count = 0 .SeriesCollection(1).Delete Loop .SeriesCollection.NewSeries .SeriesCollection(1).Name = "=""Top Plate

我正在尝试更改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)
这里是我尝试的另一种方法,但数据点仍然显示为蓝色:

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)

这只是我代码的一部分,如果需要,我可以提供额外的区域。任何帮助都将不胜感激

我认为问题在于嵌套的
块混淆了。这里有一种方法可以解决这个问题,并且仍然使用嵌套的
块:

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


这里是关于使用
块的完全限定嵌套

用第一个示例中的最后一个
替换为
选择块,使用这一行
。SeriesCollection(1).Format.Fill.ForeColor.RGB=RGB(255,0,0)
它处理了我创建的一个简单示例。非常感谢!这成功了!我仍然很好奇为什么我用的是不可接受的。如果你知道,我很想听,但如果不知道,那就别担心了。