View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default How can I time the speed of a macro?

Try this

Sub TimeMacro()
Dim StartTime As Single
Dim EndTime As Single
StartTime = Time
Debug.Print "Start Time = " & Format(StartTime, "hh:mm:ss")
'dummy loop -Your code
For t = 1 To 100000000: Next
EndTime = Time
Debug.Print "End Time = " & Format(Time, "hh:mm:ss")
Debug.Print "Elapsed Time = " & Format(EndTime - StartTime, "hh:mm:ss")
End Sub


Mike

"RyanH" wrote:

I would like to time the speed of a macro. I currently use this code, but
the StartTime and EndTime are the same, is that right? I don't think the
Time function is precise enough. Is there a accurate way of timing the speed
of a macro?

Sub TimeMacro()

Dim StartTime As Single
Dim EndTime As Single

StartTime = Time
Debug.Print "Start Time = " & StartTime

' my code here

EndTime = Time
Debug.Print "End Time = " & EndTime

Debug.Print "Elapsed Time = " & EndTime - StartTime

End Sub

--
Cheers,
Ryan