conditional formating

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

Hi,

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

Michael
 
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
 
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
 
Back
Top