You need to flip the first to IF test lines. so the first test is the target.address is B2 or B3.
new order:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address = "$B$2" Or Target.Address = "$B$3" Then
If Range("B2").Value <> "" And Range("B3").Value <> "" Then
<< rest of your code >>
Edit: I noticed for good functioning of the code you also need to move 1 end if statement form 2nd line above the end sub to just above the IF Target.colomn = 2.. tests start
see changes in code below.. I removed the parts with alle the hiding of rows in the select case .. end select section to show the changes in 1 screen
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address = "$B$2" Or Target.Address = "$B$3" Then
If Range("B2").Value <> "" And Range("B3").Value <> "" Then
If Range("B3").Value = "X" Then
Rows("8:13").EntireRow.Hidden = True
Else
Rows("8:13").EntireRow.Hidden = False
End If
End If
Select Case Range("B2").Value
'<< lot of code deleted better view on changes >>
End Select
End If ' end if inserted here to end the if test of Target.address = $B$2
If Target.Column = 2 And Target.Row = 5 Then
If Target.Value = "Yes" Then
Rows("15:15").EntireRow.Hidden = False
Else
Rows("15:15").EntireRow.Hidden = True
End If
End If
If Target.Column = 2 And Target.Row = 6 Then
If Target.Value = "Yes" Then
Rows("16:34").EntireRow.Hidden = False
Else
Rows("16:16").EntireRow.Hidden = True
End If
End If
' 1 end if was removed here
Application.ScreenUpdating = True
End Sub
Bookmarks