Is there a way to have a timer or stopwatch function in Excel.
Here's some great code for a precise timer.
Private Declare Function getFrequency Lib "kernel32" Alias _
"QueryPerformanceFrequency" (cyFrequency As Currency) As Long
Private Declare Function getTickCount Lib "kernel32" Alias _
"QueryPerformanceCounter" (cyTickCount As Currency) As Long
Public dblStart As Double
Public dblEnd As Double
Function MicroTimer() As Double
' COPYRIGHT © DECISION MODELS LIMITED 2000. All rights reserved
' returns a Double containing seconds
' uses Windows API calls to the high resolution timer
Dim cyTicks1 As Currency
Static cyFrequency As Currency
MicroTimer = 0
' get frequency
If cyFrequency = 0 Then getFrequency cyFrequency
' get ticks
getTickCount cyTicks1
' calc seconds
If cyFrequency Then MicroTimer = cyTicks1 / cyFrequency
End Function
-----------------
In your code declare a couple of vars that are doubles
Public dblStart As Double
Public dblEnd As Double
'record the start time
dblStart = MicroTimer()
' do some stuff here
' record the end time
dblEnd = MicroTimer()
' calc the elapsed time & put in the range named "Elapsed"
Range("elapsed) = dblEnd - dblStart
"Otto Moehrbach" wrote:
Tell us what you want to do. HTH Otto
"JSenew" wrote in message
...
|