本文介绍了更改图表 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 中的点颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 21:10