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

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.
 
G

Gord Dibben

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
 

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