View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Slow Performance Hiding Rows

Public Sub Hide_Rows(rng)

Application.ScreenUpdating = False

Dim r As Range
rng.EntireRow.Hidden = False
'rng.Select
For Each r In rng
'r.Select
'row = ActiveCell.row
if r.row mod 20 = 0 then
Application.StatusBar = "Row " & r.row
End if
If IsEmpty(r) Or r = "None" Then
r.EntireRow.Hidden = True
End If
Next r
Application.StatusBar = False
Application.ScreenUpdating = True

End Sub

--
Regards,
Tom Ogilvy

"Fid" wrote in message
oups.com...
I have a loop hiding blank rows. It just seems to run very slowly.
What can I do to increase the speed of this code?


Private Sub Worksheet_Activate()
Dim rng As Range
Set rng = Range(Cells(6, 7), Cells(6, 7).End(xlDown))
Hide_Rows rng

End Sub

Public Sub Hide_Rows(rng)

Application.ScreenUpdating = False

Dim r As Range
Dim row As Long

rng.Select
For Each r In Selection
r.Select
row = ActiveCell.row
Application.StatusBar = "Row " & row
If IsEmpty(r) Or r = "None" Then
Selection.EntireRow.Hidden = True
Else
Selection.EntireRow.Hidden = False
End If
Next r
Application.StatusBar = False
Application.ScreenUpdating = True

End Sub

Thanks,

Brent