laurenbattaglia
Technical User
I am trying to use Change Event to hide or unhide rows based on user input to a given cell. Here is what I have so far:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Windows("Deal_checklists_v6_1.xls").Activate
Sheets("Deal Reg. Overall").Select
'Future Purchasing Terms
If Target = Range("B29") And Target = "Y" Or Target = "y" Then
Rows("31:36").Select
Selection.EntireRow.Hidden = False 'Unhide Row
ElseIf Target = Range("B29") And Target = "N" Or Target = "n" Then
Rows("31:36").Select
Selection.EntireRow.Hidden = True 'Hide Row
'License Information
ElseIf Target = Range("B39") And Target = "Y" Or Target = "y" Then
Rows("41:45").Select
Selection.EntireRow.Hidden = False 'Unhide Row
ElseIf Target = Range("B39") And Target = "N" Or Target = "n" Then
Rows("41:45").Select
Selection.EntireRow.Hidden = True 'Hide Row
'ELA
ElseIf Target = Range("B47") And Target = "Y" Or Target = "y" Then
Rows("49:59").Select
Selection.EntireRow.Hidden = False 'Unhide Row
ElseIf Target = Range("B47") And Target = "N" Or Target = "n" Then
Rows("49:59").Select
Selection.EntireRow.Hidden = True 'Hide Row
'Term License
ElseIf Target = Range("B61") And Target = "Y" Or Target = "y" Then
Rows("63:69").Select
Selection.EntireRow.Hidden = False 'Unhide Row
ElseIf Target = Range("B61") And Target = "N" Or Target = "n" Then
Rows("63:69").Select
Selection.EntireRow.Hidden = True 'Hide Row
'Support Information
ElseIf Target = Range("B71") And Target = "Y" Or Target = "y" Then
Rows("73:84").Select
Selection.EntireRow.Hidden = False 'Unhide Row
ElseIf Target = Range("B71") And Target = "N" Or Target = "n" Then
Rows("73:84").Select
Selection.EntireRow.Hidden = True 'Hide Row
End If
End Sub
It worked for the first couple of if's but when I got to the third or forth it stopped working. I am very rusty with VB, so any help would be greatly appreciated.
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Windows("Deal_checklists_v6_1.xls").Activate
Sheets("Deal Reg. Overall").Select
'Future Purchasing Terms
If Target = Range("B29") And Target = "Y" Or Target = "y" Then
Rows("31:36").Select
Selection.EntireRow.Hidden = False 'Unhide Row
ElseIf Target = Range("B29") And Target = "N" Or Target = "n" Then
Rows("31:36").Select
Selection.EntireRow.Hidden = True 'Hide Row
'License Information
ElseIf Target = Range("B39") And Target = "Y" Or Target = "y" Then
Rows("41:45").Select
Selection.EntireRow.Hidden = False 'Unhide Row
ElseIf Target = Range("B39") And Target = "N" Or Target = "n" Then
Rows("41:45").Select
Selection.EntireRow.Hidden = True 'Hide Row
'ELA
ElseIf Target = Range("B47") And Target = "Y" Or Target = "y" Then
Rows("49:59").Select
Selection.EntireRow.Hidden = False 'Unhide Row
ElseIf Target = Range("B47") And Target = "N" Or Target = "n" Then
Rows("49:59").Select
Selection.EntireRow.Hidden = True 'Hide Row
'Term License
ElseIf Target = Range("B61") And Target = "Y" Or Target = "y" Then
Rows("63:69").Select
Selection.EntireRow.Hidden = False 'Unhide Row
ElseIf Target = Range("B61") And Target = "N" Or Target = "n" Then
Rows("63:69").Select
Selection.EntireRow.Hidden = True 'Hide Row
'Support Information
ElseIf Target = Range("B71") And Target = "Y" Or Target = "y" Then
Rows("73:84").Select
Selection.EntireRow.Hidden = False 'Unhide Row
ElseIf Target = Range("B71") And Target = "N" Or Target = "n" Then
Rows("73:84").Select
Selection.EntireRow.Hidden = True 'Hide Row
End If
End Sub
It worked for the first couple of if's but when I got to the third or forth it stopped working. I am very rusty with VB, so any help would be greatly appreciated.