#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default timer

odd question: is there code that will start a "stopwatch" (in seconds) upon
activating one sub then stop and display the time elapsed between activating
the first sub a second sub on the second sub?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default timer

Mike

Example of using a Tmer

Sub dostuff()
StartTime = Timer
For Each cell In Range("A1:AA1000")
cell.Value = "qwertyuiop"
Next
MsgBox Timer - StartTime
End Sub

Stick the StartTime = Timer line wherever you want to start timing in your Sub

MsgBox line when done.


Gord Dibben MS Excel MVP


On Fri, 16 Mar 2007 12:47:27 -0600, "mike allen"
wrote:

odd question: is there code that will start a "stopwatch" (in seconds) upon
activating one sub then stop and display the time elapsed between activating
the first sub a second sub on the second sub?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default timer

Just to supplement Gordon's response.

Timer has about 1 second resolution which isn't very good for timing code
unless you do a lot of repetitions within the timing loop.

Here is an article showing how to use more precise procedures:
..
How To Use QueryPerformanceCounter to Time Code
http://support.microsoft.com/kb/172338/en-us

--
Regards,
Tom Ogilvy



"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
Mike

Example of using a Tmer

Sub dostuff()
StartTime = Timer
For Each cell In Range("A1:AA1000")
cell.Value = "qwertyuiop"
Next
MsgBox Timer - StartTime
End Sub

Stick the StartTime = Timer line wherever you want to start timing in
your Sub

MsgBox line when done.


Gord Dibben MS Excel MVP


On Fri, 16 Mar 2007 12:47:27 -0600, "mike allen"
wrote:

odd question: is there code that will start a "stopwatch" (in seconds)
upon
activating one sub then stop and display the time elapsed between
activating
the first sub a second sub on the second sub?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default timer

Good stuff Tom

Thanks, Gord

On Fri, 16 Mar 2007 17:55:21 -0400, "Tom Ogilvy" wrote:

Just to supplement Gordon's response.

Timer has about 1 second resolution which isn't very good for timing code
unless you do a lot of repetitions within the timing loop.

Here is an article showing how to use more precise procedures:
.
How To Use QueryPerformanceCounter to Time Code
http://support.microsoft.com/kb/172338/en-us


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How Do I Set A Timer in VBA? bern11 Excel Programming 1 February 14th 07 02:35 AM
Stopping a Timer / Running a timer simultaneously on Excel Paul23 Excel Discussion (Misc queries) 1 March 10th 06 12:08 PM
timer Mike Macgowan Excel Programming 4 May 24th 05 03:27 AM
Msg Box Timer Steph[_3_] Excel Programming 13 March 18th 05 06:40 PM
API Timer seth Excel Programming 1 January 14th 04 10:40 PM


All times are GMT +1. The time now is 07:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"