View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
hko78 hko78 is offline
external usenet poster
 
Posts: 8
Default Hide Zero Rows - But Not Blank Rows

Can you tell me how to solve the same issue of not hiding the totally blank
rows but using the hiderows vbe as follows:

Sub Hiderows()
Dim lr As Long, i As Long
With ActiveSheet
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lr
If Cells(i, 3) = 0 And Cells(i, 4) = 0 Then
Cells(i, 1).EntireRow.Hidden = True
End If
Next
End With
End Sub

I would be most appreciative!

Thanks!

Heidi

"MikeF" wrote:

Hello,

Need to hide rows that a certain range sums to zero in, which the code below
does.
What it also does is hide any blank rows as well, which does not work for
the intended purpose.

Tried numerous attempts at [paraphrasing] ....

If row = 0 hide AND If row = "" do not hide

... To no avail.

Thanx in advance to anyone who can solve this.

- Mike


Sub HideRows()
ActiveWindow.DisplayZeros = True

On Error Resume Next
With Range("e13:i600")
.EntireRow.Hidden = False
For i = 1 To .Rows.Count
If WorksheetFunction.Sum(.Rows(i)) = 0 Then
.Rows(i).EntireRow.Hidden = True
End If
Next i
End With

On Error Resume Next
With Range("e13:i600")
.EntireRow.Hidden = False
For i = 1 To .Rows.Count
If WorksheetFunction.Sum(.Rows(i)) = "" Then
.Rows(i).EntireRow.Hidden = False
End If
Next i
End With

End Sub