hide rows based on cell value

D

dummster

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?
 
T

Trevor Shuttleworth

' 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top