【发布时间】:2022-01-17 23:36:42
【问题描述】:
可能是一个简单的问题,但我是新来的,很难过!
如果一个单元格包含一个值,一个形状是显示,一个是消失,但我无法让下面的代码对第二个形状做任何事情。见下文:
Sub Worksheet_Calculate()
If Range("M17").Value = "Option A" Then
Me.Shapes("Logo1").Visible = True And Me.Shapes("Logo3").Visible = False
Else
If Range("M17").Value = "Option B" Then
Me.Shapes("Logo3").Visible = True And Me.Shapes("Logo1").Visible = False
Else
Me.Shapes("Logo3").Visible = False And Me.Shapes("Logo1").Visible = False
End If
End If
End Sub
【问题讨论】:
-
And是一个布尔运算符,将两个命令放在不同的行上,没有And。
标签: excel vba if-statement