VBA Code Help - List

Contributor

Hi everyone, I have created a script that if you select from a drop-down list, it will then hide/show specific rows as seen on the code below. 

However, it has a conflict with another script that hides/show rows. How can I avoid this thing to happen? Attached were the sample data file. Thanks in advance.

rbalza_0-1627514075891.png

rbalza_1-1627514156683.png

 

 

 

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 16 And Target.Row = 3 Then
        If Target.Value = "Option 1" Then
            Worksheets("Annual").Range("66:66,75:75,134:134,171:178,244:244,246:246,256:259,263:263").EntireRow.Hidden = True
            Worksheets("Annual").Range("65:65,168:170,197:197,216:235,239:242,247:247,264:264,275:275").EntireRow.Hidden = False
        ElseIf Target.Value = "Option 2" Then
            Worksheets("Annual").Range("66:66,75:75,134:134,171:178,244:244,246:246,256:259,263:263").EntireRow.Hidden = False
            Worksheets("Annual").Range("65:65,168:170,197:197,216:235,239:242,247:247,264:264,275:275").EntireRow.Hidden = True
        ElseIf Target.Value = "All" Then
            Worksheets("Annual").Range("66:66,75:75,134:134,171:178,244:244,246:246,256:259,263:263,65:65,168:170,197:197,216:235,239:242,247:247,264:264,275:275").EntireRow.Hidden = True
        End If
    End If
    
End Sub

 

 

4 Replies

@rbalza 

What exactly is the conflict?

When I tick the show/hide (+) on the Task it will show both rows option 1 & option 2 while option 1 is being selected.

@rbalza 

This is becoming too complicated, sorry.

agreed. thanks heap for your time mate appreciated!