Hi,
I am really new to VBA so any help would really be appreciated.
I have a grouped object (ITComp) and based on the value in a cell I would like to display either one of the objects or both within the grouping.
If the certain values (IT or ITC) are not the values in the cell then nothing should be displayed.
I have written the code below but it doesn't seem to work as I would like. What seems to happen is that after the first time I change the value in the cell the object disappears for good.
Private Sub Worksheet_Change(ByVal _
Target As Excel.Range)
Dim myRange As Range
On Error Resume Next
Set myRange = Intersect(Range("DP34"), Target)
If myRange = "IT" Then
With ActiveSheet.Shapes("ITComp")
.GroupItems(1).Visible = True
.GroupItems(2).Visible = False
End With
ElseIf myRange = "ITC" Then
With ActiveSheet.Shapes("ITComp")
.GroupItems(1).Visible = True
.GroupItems(2).Visible = True
End With
Else
With ActiveSheet.Shapes("ITComp")
.GroupItems(1).Visible = False
.GroupItems(2).Visible = False
End With
End If
End Sub
Any ideas what I am doing wrong?
Thanks
Bookmarks