ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I auto hide a row if a condition isnt met? (https://www.excelbanter.com/excel-discussion-misc-queries/226639-how-do-i-auto-hide-row-if-condition-isnt-met.html)

Brian

How do I auto hide a row if a condition isnt met?
 
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.

Gord Dibben

How do I auto hide a row if a condition isnt met?
 
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

On Fri, 3 Apr 2009 13:12:13 -0700, Brian
wrote:

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.




All times are GMT +1. The time now is 07:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com