![](/img/trans.png)
[英]How can I make the cell colour RGB value change based on cell's value? (in Excel)
[英]How to make a chart series change colour based on a cell value
我正在尝试根据单元格中的特定值来更改图表系列(点)的颜色。 但是,我不断收到一个对象必需的错误。
这是我的代码
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 12 And (Target.Row >= 2 And Target.Row <= 37) Then
If Target.Value = "Stage Gate 5" Then Sheet15.ChartObjects(1).Chart.SeriesCollection(2).Points(1).Interior.Color = RGB(167, 34, 110)
Else
MsgBox ("error")
End If
End If
End Sub
我的想法是,我有一个条形图,上面带有项目的开始和结束日期,并且它们经过阶段门,我需要根据阶段门来更改每个条的颜色。
任何人都能提供的任何帮助将不胜感激。
谢谢
尝试这个:
Private Sub Worksheet_Calculate()
If Range("M2") = "Stage Gate 5" Then
Sheet15.ChartObjects(1).Chart.SeriesCollection(2).Points(1).Interior.Color = RGB(167, 34, 110)
Else
Msgbox "error"
End If
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.