I am trying to use the following code to display how long a series of commands took to run. In this example case, I expected it to come back with "10" or something similar.
Instead it comes back with:
What is going on and how can I format this correctly?
Sub timeyWimey()
Dim t1 As Date
Dim t2 As Date
Dim timeTaken As Date
t1 = Now()
Application.Wait (Now + TimeValue("0:00:10"))
t2 = Now()
timeTaken = t2 - t1
MsgBox timeTaken
End Sub
Edit:
Final Code after some great Answers:
Sub timeyWimey()
'Dim t1 As Double
'Dim t2 As Double
t1 = Now()
Application.Wait (Now + TimeValue("0:00:10"))
t2 = Now()
timeTaken = t2 - t1
MsgBox Format(timeTaken, "nn:ss.000")
End Sub
Results in:
BAM! Problem Solved! Thanks everyone for your help!