hide row based on cell value



i have a worksheet that i want to hide rows based on cell value.

if cell B3 is blank, then i need rows 4,5 and 6 to be hidden, B3 contains
data than row 4 is visible.

if cell H3 is blank, then rows 5 and 6 need to be hidden. if b3 and h3 have
data, then rows 4 and 5 are visible.

if cell n3 is blank then row 6 is hidden.

i have the following so far:

Private Sub Worksheet_change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address(0, 0) = "P28" Then
Select Case LCase(Target.Value)
Case "target": MainMenu 'this brings up a user input box and works
End Select
End If

If Target.Address(0, 0) = "B3" Then
If Range("B3") <> "" Then Call hideum
End If
Application.EnableEvents = True

End Sub
Sub hideum()
Dim i As Long
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
If Cells(i, 1).Value = "XXX" Then
Rows(i).Hidden = True
End If
End Sub

i can run the hideum macro manually but it does not fire on it's own. any

Dave Peterson

It works ok for me.

Are you sure that it's failing--maybe you don't have any XXX in column A
(upper/lower case matters in your code).


probably would have helped if i had the code in the worksheet and not the



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