View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
david mcritchie david mcritchie is offline
external usenet poster
 
Posts: 691
Default Runs fast then slow

You should avoid changing the selection within a macro
if you want to make bad coding run faster then turn off
screen updating and turn off calculation.
http://www.mvps.org/dmcritchie/excel/slowresp.htm
In fact you can sometimes beat out better that does not
turn off screen updating and turn off calculation, but that
doesn't really solve your problem.

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"rpw" wrote in message ...
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