A Timer with Excel VBA

Creating a timer with VBA is a useful tool to have stored in your personal macro workbook. It allows you to check the speed of your procedures while they run.  The benefits are numerous as the code will allow you to run VBA code a different stages of its life to compare how quickly or slowly the VBA procedure runs.  It will also allow you to trial different approaches against one another.   The following is the Excel VBA code for the task.

Sub timer()
Dim t As Date

t=Now()
'Your Code goes in here.
MsgBox Format(Now() - t, "hh:mm:ss")

End Sub

The Excel VBA itself is very simple. You simply declare a variable as a date, assign the date to this instant and then check the time at the end of the macro with the time at the start of the macro and the result is the answer. Simply put the name of your procedure in place of the 'Your Code goes in here or paste your macro coding over this text.