ganesh_s86
New Member
- Joined
- Aug 30, 2011
- Messages
- 13
I am trying to create a macro to automatically hide/unhide rows based on input given to cell c16. Unfortunately the code below seems to have no effect . I have used this code in the View code option when right clicking sheet tab.
Please help debug this.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = c16 Then
Select Case Target.Value
Case 1
Range("26:40").EntireRow.Hidden = True
If Target.Address = "$D$20" And Target.Value = "Release" Then
Range("23:24").EntireRow.Hidden = True
Else
Range("23:24").EntireRow.Hidden = False
End If
Case 2
Range("26:33").EntireRow.Hidden = False
Range("33:40").EntireRow.Hidden = True
If Target.Address = "$D$28" And Target.Value = "Release" Then
Range("31:32").EntireRow.Hidden = True
Else
Range("31:32").EntireRow.Hidden = False
End If
Case 3
Range("26:40").EntireRow.Hidden = False
If Target.Address = "$D$36" And Target.Value = "Release" Then
Range("39:40").EntireRow.Hidden = True
Else
Range("39:40").EntireRow.Hidden = False
End Select
End If
End Sub
Please help debug this.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = c16 Then
Select Case Target.Value
Case 1
Range("26:40").EntireRow.Hidden = True
If Target.Address = "$D$20" And Target.Value = "Release" Then
Range("23:24").EntireRow.Hidden = True
Else
Range("23:24").EntireRow.Hidden = False
End If
Case 2
Range("26:33").EntireRow.Hidden = False
Range("33:40").EntireRow.Hidden = True
If Target.Address = "$D$28" And Target.Value = "Release" Then
Range("31:32").EntireRow.Hidden = True
Else
Range("31:32").EntireRow.Hidden = False
End If
Case 3
Range("26:40").EntireRow.Hidden = False
If Target.Address = "$D$36" And Target.Value = "Release" Then
Range("39:40").EntireRow.Hidden = True
Else
Range("39:40").EntireRow.Hidden = False
End Select
End If
End Sub