Monday, March 17, 2014

How to know the running time of a macro (VBA-Excel)?

Just use the following code and the running time of your macro will be printed, in seconds, on the immediate window:

Sub macro1()

Dim starttime, endtime As Double

starttime = Now

' your code here

endtime = Now
Debug.Print "Macro ran successfully in " & DateDiff("s", starttime, endtime) & " seconds"

End Sub

No comments: