【发布时间】:2015-01-24 02:36:09
【问题描述】:
我正在做一个学校项目,想在图片顶部叠加箭头来描述交通流量。如果流量很少(“A1”
Sub DetermineArrowColor()
Dim ncars As Double
Range("A1").Value = ncars
If ncars < 20 Then
'change arrow color to green
ActiveSheet.Shapes.Range(Array("Down Arrow 1")).Select
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 176, 80)
.Transparency = 0
.Solid
Else
'change arrow color to something else
ActiveSheet.Shapes.Range(Array("Down Arrow 1")).Select
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 30, 30) 'whatever the numbers are for the color red
.Transparency = 0
.Solid
End If
End Sub
【问题讨论】:
-
你能指定你在哪里得到编译错误,是什么编译错误?
-
我没有仔细看,但我发现你错过了
End With声明...... -
我不是这方面的专家,但我似乎记得有一个叫做
conditional formatting的东西可以让你根据它的价值给东西上色 - 试试谷歌搜索吧。 -
@JohnBustos 不错,这显然是答案。
标签: excel if-statement colors vba