hide rows based on cell value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm new to Excel and VBA. I try to hide rows based on whether the user enters
a specific word(s)/phrase into a specific cell. For example, if cell M49 has
a value of "i love lucy", then unhide rows 50 through 55, if cell M49 is
empty or has any other value than "i love lucy", then hide the rows. How do I
implement that?
 
' Sheet 1 Class Module
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("M49")) Is Nothing Then Exit Sub
If LCase(Range("M49").Value) = "i love lucy" Then
Range("A50:A55").EntireRow.Hidden = False
Else
Range("A50:A55").EntireRow.Hidden = True
End If
End Sub

Regards

Trevor
 
Back
Top