View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John John is offline
external usenet poster
 
Posts: 2,069
Default Hide Zero Rows - But Not Blank Rows

probably a better way to do this but adapting your code I think this may do
what you want:

Sub HideRows()
ActiveWindow.DisplayZeros = True
On Error Resume Next
Application.ScreenUpdating = False
With Range("e13:i600")
For i = 1 To .Rows.Count
If WorksheetFunction.CountA(.Rows(i)) 0 Then
If WorksheetFunction.Sum(.Rows(i)) = 0 Then
.Rows(i).EntireRow.Hidden = True
Else
.Rows(i).EntireRow.Hidden = False
End If
End If
Next i
End With
Application.ScreenUpdating = True
End Sub
--
JB


"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