View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Hiding Empty Rows

Try this. It ran in less than a second for me. Let me know how it goes.

Sub Test_Hide_Rows()

Dim lngRow As Integer
Application.ScreenUpdating = False
With ActiveSheet
For lngRow = 8 To 359 'All Rows
If .Cells(lngRow, 4) = 0 Then
If .Cells(lngRow, 4).End(xlToRight).Column 15 Then
.Cells(lngRow, 4).EntireRow.Hidden = True
End If
End If
Next lngRow
End With
Application.ScreenUpdating = True

End Sub

Regards,

OssieMac



"AJ Master" wrote:

I have been using the code below to hide empty rows in a worksheet.
Originally I was only evaluating 12 columns (one for each month of
the year) in each of about 100 rows to determine whether to hide the
entire row. The number of rows has grown to about 350 and now the
code runs rather slow. About 7-10secs versus the 2 secs it used to
take. Anyone with any ideas on how to improved the speed of this
code??

Dim bytCol As Byte
Dim lngRow As Integer
Application.ScreenUpdating = False

For lngRow = 8 To 359 'All Rows
For bytCol = 4 To 15 'Columns D-O
If ActiveSheet.Cells(lngRow, bytCol) < 0 Then Exit For
If bytCol = 15 Then ActiveSheet.Rows(lngRow).Hidden = True
Next bytCol
Next lngRow

Application.ScreenUpdating = True

Thanks....AJ