I am trying to hide/unhide rows in excel based on a specific cell value. If the value is 0 all rows are to be hidden. If the value is 1 then rows 36 to 1000 are hidden. If the value is 2 then rows 72 to 1000 are hidden, if it is 3 then 108 to 100 are hidden, etc until all cells can be unhidden...
Here is what I have so far... It works for hiding/unhiding, but if I change the number from 0 to 1 and then from 1 to 2 it does not update sometimes...
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = ("$E$3") And Target.Value = 0 Then
Sheets("Abutments").Rows("5:1000").EntireRow.Hidden = True
ElseIf Target.Address = ("$E$3") And Target.Value = 1 Then
Sheets("Abutments").Rows("36:1000").EntireRow.Hidden = True
ElseIf Target.Address = ("$E$3") And Target.Value = 2 Then
Sheets("Abutments").Rows("72:1000").EntireRow.Hidden = True
Else
Sheets("Abutments").Rows("5:1000").EntireRow.Hidden = False
End If
End Sub
BONUS is there a way for the vba code to reference the changing cell if the cell contained a formula?