Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code Timer

Status
Not open for further replies.

richand1

Programmer
Feb 4, 2004
88
GB
I've searched Tek-Tips and the web extensively but I can't find any help with some code (in VBA for Excel 97) that would start a timer when my code starts, and return the total time elapsed when it has finished.

Can anyone help?
 
Could you put two parameters "StartTime" and "EndTime" at the start of your code and at the end of your code respectively and then return the difference at the end of the code.
 
Have a look here:

thread707-591199

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
The VBA function "Timer" can be used to time code. Timer counts the number of seconds that have elapsed since midnight and is good to fractions of a second (returns a floating point Single).
Code:
StartTime = Timer
'Your code goes here
FinishTime = Timer

TotalTime = FinishTime - StartTime
[code]
I have run across some code that makes calls to the system timer and it was more precise than the VBA timer function.  Unfortunately, I did not make a note of where I found it.  It may be here in Tek-Tips somewhere.  Try searching the VB area of Tek-Tips.

Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top