View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bill Martin[_2_] Bill Martin[_2_] is offline
external usenet poster
 
Posts: 105
Default VBA - Timing A Block Of Lines

ajocius wrote:
Group,
I'm trying to find out how long blocks of code take to execute in
order to balance my program. Below is a sample of programming I'm
using to attempt this. I doesn't seem to work. Any help for a novice
would be awesome.

Dim StartTime As Long
Dim EndTime As Long
Dim TotalTime As Long
..
..
..
..
..
StartTime = Now()
..
..
..
EndTime = Now()
TotalTime = EndTime - StartTime





Tony

------------------------

If you're trying to time a few lines of code, I don't know how you can do it
directly given the vagaries of applications interacting with the operating
system. Even if you could do it, you'd get meaningless numbers all over the map.

What I have done is something similar to what you're trying, but with a For/Next
loop around the code in question to make it execute 1,000 times or a 1,000,000
times or whatever is necessary to make the lines of code take perhaps 30 seconds
to execute.

In that sort of time frame you can either do something like you're trying, or
even just use a stop watch on it.

Good luck...

Bill