Get Milliseconds in a timestamp
I think the last line should be:
Test = timeTaken * 86400# * 1000#
--
Regards
Vergel Adriano
"Joel" wrote:
I believe time is acurate to a timer tick in a PC and is in days. You have
to multiply by 3600 (days to seconds) and then by 1000 to get millisconds. I
added some dummy execution statements to show the accuracy of the timer. i
also declared variiables as double to get greatter precision.
Function Test() As Double
Dim Starttime As Double
Dim EndTime As Double
Starttime = Now()
Set MyRange = ActiveSheet.Range("C1:Z10000")
x = 0
For Each cell In MyRange
cell = 1234
Next cell
EndTime = Now()
timeTaken = EndTime - Starttime
'convert days to milliseconds
Test = timeTaken * 3600# * 1000#
End Function
"Dave" wrote:
I'm trying to figure out how long my macro is taking to run, and I want it as
accurate as possible... it would be great if I could get it down to
millisecond precision, is this possible?
Something like:
function test()
startTime = Now()
...
(function code)
...
endTime = Now()
timeTaken = endTime - startTime
test = timeTaken
end function
|