更改图中最后一个点的颜色 [英] Change color of the last point in a graph

查看:117
本文介绍了更改图中最后一个点的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VBA中创建了一个图形

I created a graph in VBA

但是,我想要的最后一点是使用另一种颜色红色)

But i want to the last point i have done is in another color (red)

这是我的代码:

Sub Macro2()
'
' Macro2 Macro
'

'

    i = Range("G3").Select

    j = Range("D3").Select

     With ActiveChart.ChartArea.Select
            i.MarkerBackgroundColor = RGB(250, 250, 250)
            j.MarkerForegroundColor = RGB(250, 250, 250)
    End With
End Sub

在我是X abscisse和j是最后一点的Y表示!

In i is the X abscisse and j is the Y abscisse of the last point !

感谢您的任何建议

推荐答案

此代码将图表上的最后一个标记设置为红色。请注意,红色的RGB值为(255,0,0)

This code will set the last marker on the chart to red. Note the the RGB value for red is (255, 0, 0)

Sub SetLastMarkerRed()

    Dim ws As Worksheet
    Dim ch As Chart
    Dim sc As SeriesCollection
    Dim s As Series
    Dim p As Point

    Set ws = ThisWorkbook.ActiveSheet
    Set ch = ws.ChartObjects(1).Chart
    Set sc = ch.SeriesCollection
    Set s = sc.Item(1)
    Set p = s.Points(s.Points.Count)
    p.MarkerBackgroundColor = RGB(255, 0, 0)
    p.MarkerForegroundColor = RGB(255, 0, 0)

    Set ws = Nothing
    Set ch = Nothing
    Set sc = Nothing
    Set s = Nothing
    Set p = Nothing

End Sub

< img src =https://i.stack.imgur.com/96ZnR.gifalt =在此输入图像说明>

这篇关于更改图中最后一个点的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆