more help with a hide macro

A

Awoll

Hello again,

I got some help with a hide macro for searching for a spcific word, and it
worked great. Now i'm trying to hide any row that has a 0 value in the b
column. if it is any other number. I want it to remain. I tried changing the
macro, but it hides everything and can't get it to work.

Any help would be greatly appreciated.

Thanks,

Aaron
 
T

Tom Ogilvy

With only limited information:

set rng = Columns(2).SpecialCells(xlConstants,xlNumbers)
for each cell in rng
if cell.Value = 0 then
cell.EntireRow.Hidden = True
else
cell.Entirerow.Hidden = False
end if
Next

if the zeros are produce by formula, change xlconstants to xlFormulas
 
A

Awoll

Awsome, the zero are produced by a if function so i'm hoping that the
xlForumulas will work. Is there anyway to specify the worksheet that it runs
on?
 
T

Tom Ogilvy

Dim rng as Range, cell as Range
With Worksheets("Sheet3")
set rng = .Columns(2).SpecialCells(xlFormulas,xlNumbers)
End With
for each cell in rng
if cell.Value = 0 then
cell.EntireRow.Hidden = True
else
cell.Entirerow.Hidden = False
end if
Next
 

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