View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
david mcritchie david mcritchie is offline
external usenet poster
 
Posts: 691
Default Excel 2000 Slow Loops

Hi .....,
If you tell Excel that you have 65536 rows it will take several minutes
just to process the cells in 1 column. You main problem is that you
are almost certainly processing non existent data.

Without knowing what you are doing can't really tell you much.
Some things (not many) can be done without loops.

Take a look at
Slow Response, Memory Problems, and Speeding up Excel
http://www.mvps.org/dmcritchie/excel/slowresp.htm
and
Proper, and other Text changes -- Use of SpecialCells
http://www.mvps.org/dmcritchie/excel/proper.htm

Look particularly for such things as INTERSECT, SpecialCells,
turning off calculation and screen updating.

If you do not have data in your last row unless there is a value
in Column A also then you could use something like ...
Looping on items would be faster.

sub DoNothing()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim n As Long, i As Long
n = Cells(Rows.Count, 1).End(xlUp).Row
MsgBox "Starting up from Row " & n
For i = n To 1 Step -1 'more likely to 2 instead of 1
'...ooo ---- your code here ---- ooo
Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

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

"scain2004 " wrote
What looping method is the fastest if you have nested loops? I've got
several ( For i = Range("A65536") To 1 Step -1 ) loops that take
forever to run. Any suggestions on how to speed this up?