Macro to hide rows

D

Doug

What is a good macro to hide rows in a table selected range that have "0"
values?
Reason for wanting this if I filter any one column for values of "0" then it
is likely to hide values in other columns that are not "0". I want to show
all rows that have any value other than "0" in a selected range. Can you help
me please?
 
M

Mike H

Doug,

Try this. Select a range and then run the code

Sub Hide_Me()
For Each c In Selection
If c.Value <> "" And c.Value = 0 Then
c.EntireRow.Hidden = True
End If
Next
End Sub

Mike
 
D

Doug

I think this is hiding a row if it has a single "0" value. I am needing it to
hide it if they are all "0" values. When I tried it, ran for about 1 minute
and timed out after hiding about 40 rows at the top of my table.
 
B

B Lynn B

How about, instead of code, add a column with formula that resolves to True
if your condition is met, then just apply a filter?

e.g. new column A, with formula in A2 "=or(b2<>0,c2<>0,d2<>0,e2<>0)" with
arguments for as many cells to the right need to be tested for 0 value.
 
D

Doug

Thank you
--
Thank you!


B Lynn B said:
How about, instead of code, add a column with formula that resolves to True
if your condition is met, then just apply a filter?

e.g. new column A, with formula in A2 "=or(b2<>0,c2<>0,d2<>0,e2<>0)" with
arguments for as many cells to the right need to be tested for 0 value.
 

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