更改图表 Excel VBA 中的点颜色

编程入门 行业动态 更新时间:2024-10-26 20:22:24
本文介绍了更改图表 Excel VBA 中的点颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这张图表,如果图表中的任何一点超过特定限制,那么它的颜色应该改变.


谁能建议我如何在 VBA 中获取图表,然后应用这种条件,例如我想更改上图中最高点的颜色.任何帮助将不胜感激.

解决方案

Using: ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart1").Chart.SeriesCollection(1)>

每个点的颜色为.Points(PointNumber).Interior.Color

你必须循环的点数是.Points.Count

每个点的值是.Points(PointNumber).Value

标记本身的颜色(仅适用于折线图、散点图和雷达图):

.Points(PointNumber).MarkerBackgroundColor = RGB(0,255,0) ' 绿色.Points(PointNumber).MarkerForegroundColor = RGB(255,0,0) ' 红色.Points(PointNumber).MarkerStyle = xlMarkerStyleCircle '改变形状

I have this chart in which if any point in graphs exceeds specific limit then its color should change.


can anyone suggest me how to get the chart in VBA and then apply this kind of condition e.g i want to change the color of highest point in the above graph . Any help would be highly appreciated.

解决方案

Using: ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart1").Chart.SeriesCollection(1)

Color of each point is .Points(PointNumber).Interior.Color

The number of points you have to cycle though is .Points.Count

The value of each point is .Points(PointNumber).Value

colors of the markers themselves (Applies only to line, scatter, and radar charts):

.Points(PointNumber).MarkerBackgroundColor = RGB(0,255,0)    ' green
.Points(PointNumber).MarkerForegroundColor = RGB(255,0,0)    ' red
.Points(PointNumber).MarkerStyle = xlMarkerStyleCircle ' change the shape

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

更多推荐

[db:关键词]

本文发布于:2023-03-31 20:40:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/813749.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图表   颜色   Excel   VBA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!