Slow Performance Hiding Rows
Brent,
This is a little simpler and should run much faster.
It works from the bottom up, turns off the display
of page breaks and doesn't select anything.
'-----------------------
Public Sub Hide_Rows(ByRef rng As Excel.Range)
Dim r As Long
Application.ScreenUpdating = False
For r = rng.Rows.Count To 1 Step -1
Application.StatusBar = "Row " & r
ActiveSheet.DisplayPageBreaks = False
If Len(rng(r).Value) = 0 Or rng(r).Value = "None" Then
rng(r).EntireRow.Hidden = True
Else
rng(r).EntireRow.Hidden = False
End If
Next r
Set rng = Nothing
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
'------------------------
Jim Cone
San Francisco, USA
"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
|