View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Hide Row If Any Cell In It = 0

I note from your reply to Per you have REF errors, this copes with those and
blank cells

Dim LastRow As Long
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:J" & LastRow)
For Each c In MyRange.Rows
Set RowRange = MyRange.Rows(c.Row)
For Each cl In RowRange.Cells
If Not IsError(cl.Value) Then
If cl.Value < "" And cl.Value = 0 Then
Rows(cl.Row).Hidden = True
Exit For
End If
End If
Next cl
Next c
End Sub


--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Mike H" wrote:

Hi,

try this

Sub Sonic()
Dim MyRange As Range
Dim RowRange As Range
Dim LastRow As Long
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:J" & LastRow)
For Each c In MyRange.Rows
Set RowRange = MyRange.Rows(c.Row)
For Each cl In RowRange.Cells
If cl.Value < "" And cl.Value = 0 Then
Rows(cl.Row).Hidden = True
Exit For
End If
Next cl
Next c
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"robzrob" wrote:

Hello All

Searched high and low amongst the forums for this and found some close
solutions, but can't seem to make any work.

I have Rows 1-100 & Cols A-J all with formulas or text in them. If
the result of any of the formulas in any of the that range is 0, I
want the entire row hidden.

Cheers
.