How do I auto hide a row if a condition isnt met?

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I have a MS Query data being returned to Excel and I want to evaluate certain
conditions of that data. Based on those conditions I want to display a row
or hide it so I can directly print my worksheet without resorting or turning
on autofilter.
 
Autofilter is pretty easy to use, but I guess you could try a macro.

Sub HideBlank_Zeros_Rows()
'using set column B
Dim RngCol As Range
Dim I As Range
Set RngCol = Range("B1", Range("B" & Rows.Count). _
End(xlUp).Address)
For Each I In RngCol
If I.Value = "" Or I.Value = "0" Then _
I.entirerow.Hidden = True
Next I
End Sub

Adjust for your "certain conditions"


Gord Dibben MS Excel MVP
 
Back
Top