Skip to main content

Adding a timer to the script

You can add the following lines to a script to check how long it takes to process.  The commented lines show how to get the date and time.  The timer gives the seconds and milliseconds so it is great for using as a timer.

Since the Timer function counts seconds from midnight if your run time passes midnight then it will return an inaccurately large result.

Snippet

Sub Main
    Dim tmStartTime As Long
    Dim tmFinishTime As Long
    tmStartTime = Timer

    'enter your code to time
   
    tmFinishTime = Timer
    MsgBox tmFinishTime - tmStartTime
End Sub