View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RPW RPW is offline
external usenet poster
 
Posts: 52
Default Runs fast then slow

Hi everyone,

I have this code that runs very fast the first time I open the workbook and
run it. All subsequent runs are about 1/2 to 1/3 the speed. I don't
understand why the slow down. Can someone explain it to me?

Would I be better off taking the hide/unhide rows portion of it and making
it a function and include it as part of the cell formula - would that slow
the workbook way down?

Thanks in advance for your responses. Here's the code:

Dim RowCounter As Integer
Dim BreakCounter As Integer
Dim CellValue As String

Worksheets("Summary Sheet").Activate
Worksheets("Summary Sheet").Range("A1").Select

For RowCounter = 1 To 976
CellValue = Selection
If CellValue < "Skip" Then
Selection.EntireRow.Hidden = True
Selection.Offset(1, 0).Range("A1").Select
Else:
Selection.EntireRow.Hidden = False
Selection.Offset(1, 0).Range("A1").Select
End If
Next RowCounter

Worksheets("Summary Sheet").Range("p249").Select

For BreakCounter = 1 To 4
CellValue = Selection
If CellValue = "Break" Then
Selection.PageBreak = xlPageBreakManual
Else: Selection.PageBreak = xlPageBreakNone
End If
Selection.Offset(241, 0).Range("a1").Select
Next BreakCounter

ActiveSheet.PrintPreview

Worksheets("Summary Sheet").Range("a1:a1000").Select
Selection.EntireRow.Hidden = False
Worksheets("Basic Pricing").Activate
Worksheets("Basic Pricing").Range("d3").Select
--
rpw