Am Am Am in tomg Am lought over toble clast =
...形状是'test'和单元格值" x11"。我遇到的错误是该对象不支持此属性或方法...
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
将您的代码更改为此,用语句错误。您没有使用工作表,因此您无法使用.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