[英]Modifying shape colour based on cell value
Am looking to modify the shape colour based on a linked cell value ... 我希望根据链接的单元格值修改形状颜色...
The shape is 'test' and the cell value "X11". 形状为“测试”,单元格值为“ X11”。 I'm getting the error that the object does not support this property or method ...
我收到对象不支持此属性或方法的错误...
Sub CChange()
Dim ws As Worksheet
Set ws = ThisWorkbook.ActiveSheet
With ws.Shapes.Range(Array("test"))
If .Range("X11") = 1 Then
.Fill.ForeColor.RGB = RGB(18, 38, 43)
ElseIf .Range("X11") = 2 Then
.Fill.ForeColor.RGB = 0
End If
End With
End Sub
Change your code to this , your with statement is wrong. 将您的代码更改为此,您的with语句错误。 You are not working with worksheet hence you cannot access range with .Range.
您不使用工作表,因此无法使用.Range访问范围。
Sub CChange()
Dim ws As Worksheet
Set ws = ThisWorkbook.ActiveSheet
With ws.Shapes.Range(Array("test"))
If ws.Range("X11") = 1 Then
.Fill.ForeColor.RGB = RGB(18, 38, 43)
ElseIf ws.Range("X11") = 2 Then
.Fill.ForeColor.RGB = 0
End If
End With
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.