Conditionally Hide Rows

M

Mos.StaLL

HI All,

How do I conditionally rows if a certain cell = 0? For example, if
any cell within range BA5:BA37 =0 then hide row. Any help will be
appreciated. Thanks.

James
 
D

Dave Peterson

How about just selecting that column and doing data|Filter|autofilter.

Then you can show cells not equal to 0.
 
M

Mos.StaLL

How about just selecting that column and doing data|Filter|autofilter.

Then you can show cells not equal to 0.

Thanks for the help, but I've tried that and it does not refresh when
I import new data. I'm looking for something that updates when I
import new data. Thanks for you help so far.
 
C

CLR

If you are importing your data with MSQuery, then do it with a macro and
include the Filtering feature Dave described.

Vaya con Dios,
Chuck, CABGx3
 
T

Tom Hutchins

You could use a macro with a Worksheet_Change event like the following:

Private Sub Worksheet_Change(ByVal Target As Range)
Const MyRng = "BA5:BA37"
Dim c As Range
For Each c In Range(MyRng)
If c.Address = Target.Address Then
If Target.Value = 0 Then
Target.EntireRow.Hidden = True
Else
Target.EntireRow.Hidden = False
End If
End If
Next c
End Sub

Right-click on the tab of the sheet where you want to use this, then select
"View code". Paste the function into the worksheet code module when the VB
Editor appears.

Hope this helps,

Hutch
 
T

Tom Hutchins

Worksheet. A "Worksheet_SelectionChange" subroutine may appear by default
with no code. Ignore it and paste the code I sent in the same module below it.

Hutch
 
Top