How to hide rows on condition

E

exceluser

Hello all,

Would anyone be able to provide me with some guidance on how I woul
hide or unhide rows on a given condition?

e.g.
Say if cell A1 had value "HIDE" and cell A2 had value "C" then hide ro
"C"?

Thanks in advance,

-E
 
E

exceluser

Sorry, I meant "row 3".

Perhaps a simpler example....

If a cell is some value (let's say "0"), I want to hide the entire row


e.g.

A B C
1 dog 3
2 foo 0
3 bar 4
4 big 2
5 man 6

should display as this

A B C
1 dog 3
3 bar 4
4 big 2
5 man 6


Can I do this? I'm trying to use PivotTables and this might sort of d
the trick (i.e. I am unchecking the box for where the values in "B" ar
"0" so they are not displayed in the PivotTable).

Anyone know of any other way to do this?

Thanks
 
D

Dave Peterson

If C represents a number:

Option Explicit
Sub testme01()

With ActiveSheet
If LCase(.Range("a1").Value) = "hide" Then
If IsNumeric(.Range("a2").Value) Then
If .Range("a2").Value > 0 Then
If .Range("a2").Value < .Rows.Count Then
.Rows(.Range("a2").Value).Hidden = True
End If
End If
End If
End If
End With

End Sub
 
Top