conditional formating

M

Michael

Hi,

Is it possible to automaticaly hide rows if all values(lets say B10:Z10) in
that row are 0?

Michael
 
D

Don Guillett

Sub hiderowifallzeros()
For Each c In Range("a5:a15")
If Application.CountIf(Range("b10:z10"), 0) > 0 _
Then c.EntireRow.hidden=true
Next
End Sub

This will hide rows from 5-10 if col A is blank
Sub hizezerorows()
For Each c In Range("a5:a15")
If Application.IsNumber(c) And c = 0 Then c.EntireRow.Hidden = True
Next
End Sub
 
D

Dave Peterson

This isn't automatic, but it's pretty quick.

I'd insert a helper column and put something like:
=countif(b10:z10,0)
and drag down

Then apply Data|Filter|autofilter to that range (or just column) and hide the
rows that evaluate to 25.

And if you really wanted a macro:

Option Explicit
Sub testme01()

Dim myRow As Range
Dim myRng As Range

With ActiveSheet
Set myRng = .Range("b10:Z" & .Cells(.Rows.Count, "Z").End(xlUp).Row)
For Each myRow In myRng.Rows
If Application.CountIf(myRow, 0) = myRow.Cells.Count Then
myRow.EntireRow.Hidden = True
End If
Next myRow
End With
End Sub
 

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