Sub ShowTimer()
Dim T As Single
T = Timer
'Run some code
Do While Timer - T < 3
Loop
Debug.Print Format(Timer - T, "#.0##")
'OR
MsgBox "Your macro took " & Format(Timer - T, "#.0##") & " seconds to run"
End Sub
In the example below the function "Timer" is used. Timer is the number of seconds past midnight. You have to store the value of Timer at the beginning of your macro and then compare that value to Timer again at the end of your macro.
Code:Sub ShowTimer() Dim T As Single T = Timer 'Run some code Do While Timer - T < 3 Loop Debug.Print Format(Timer - T, "#.0##") 'OR MsgBox "Your macro took " & Format(Timer - T, "#.0##") & " seconds to run" End Sub