Speed up Excel execution
Peter T wrote:
You already have a lot of good general advice about speeding things up.
However it seems there's something else going on, perhaps unnecessary
looping or processing of your own code, something calculating in the
workbook or a combination.
Any events being triggered - disable, or udf's - calc to manual (ensure no
possibility of not getting reset when done due to errors). If disabling
speeds things up find out why, can things be changed to avoid disabling.
Might be worth adding a debug log. Set a global boolean debug flag and call
a routine to either debug.print or write to a file, say at start/end of
proc's and loops etc, and of course record time (try the GetTickCount API).
If bLog then meLog "ProcName " & OtherInfo
Also perhaps record sheetnames & large range address's being processed, if
applicable.
Regards,
Peter T
"Sinus Log" wrote in message
...
Searching in Google Groups gave me some useful results about
speeding up execution:
- recalc off,
- application.screenUpdating=false,
- declare all variables, with integer the best and variant
the worst,
- after editing a module, copy the code, delete the module,
create a module, insert the copied code (I am going to do
it, although I can't believe it will change a thing),
- keep comments to the minimum (unbelievable too: since the
code is compiled, not interpreted - or is it ? -, the
comments are read just once),
- keep VBA closed (this one, I discovered by myself).
But I am sure there is something else: the order of the
sheets in the workbook, the order of the cell contents, and
things like that. Here is why.
I am working on a workbook with 5 sheets. Execution takes 13
seconds, whatever changes I make in the workbook, and even
if there is no change (pressing F9 repeatedly, for
instance). I tried something: I cut all cells in sheet2 and
pasted them at the bottom of sheet1. Now, when I make a
change in sheet5, execution takes half a second (but still
13 seconds when I make a change in the other sheets).
Reversing, that is cutting all cells from sheet1 and pasting
them at the bottom of sheet2, yields 13 seconds execution
time everywhere.
I'd be grateful if someone would give me some guidelines.
And also, I would appreciate a comment about the 2 things
I can't believe, above.
Thanks
Thanks to all for the info. I'll need a lot of time checking
and modifying my workbook. There are so many tests to do.
I'll post a feedback as soon as possible.
|