我有一个项目使用Worksheet_Change
子项根据特定单元格的值(在本例中为B23
)使某些图像可见或不可见。
现在我尝试添加第二个条件,根据不同单元格中的值(在这种情况下为B24
)使不同的图像集可见/不可见。
问题是,我现在遇到"Invalid or Unqualified Reference"
错误,看起来它与".pictures"
一块有关。以下是我试图运行的代码:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Me.Range("$B$23,$B$24")) Is Nothing Then Exit Sub
If Target.Address = "$B$23" Then
Select Case Target.Value
Case "driving"
.Pictures("Auto_Map_Labeled").Visible = True
.Pictures("Bicycle_Map_Labeled").Visible = False
.Pictures("Pedestrian_Map_Labeled").Visible = False
Case "bicycling"
.Pictures("Auto_Map_Labeled").Visible = False
.Pictures("Bicycle_Map_Labeled").Visible = True
.Pictures("Pedestrian_Map_Labeled").Visible = False
Case "walking"
.Pictures("Auto_Map_Labeled").Visible = False
.Pictures("Bicycle_Map_Labeled").Visible = False
.Pictures("Pedestrian_Map_Labeled").Visible = True
End Select
ElseIf Target.Address = "$B$24" Then
Select Case Target.Value
Case "visible"
.Pictures("Thumbs_Up").Visible = True
Case "invisible"
.Pictures("Thumbs_Up").Visible = False
End Select
End If
End Sub
任何想法可能会出错?我应该注意到我对VBA很新,所以寻找最简单的解决方案。