Tuesday, February 1, 2011

Time my macro

Want a quick way to time your macro or demonstrate to your user how fast your macro runs?  Here is a quick code that will pop up a message box displaying the time it took!


Sub Time()
Dim Start As Long, Ending As Long, Time As Long
    Start = Timer()
        'insert macro here
    Ending = Timer()
    Time = Ending - Start
    MsgBox "Time lapsed: " & Format(Time / 60, "###.00") & " minutes or " & Time & " seconds"
End Sub

No comments: