Hi unmarked helicopter,
Firstly, thanks for your insightful postings. Yes, I meant minutes seconds and milliseconds, as opposed to "minutes and milliseconds" earlier, a simple typo.
Also I understood the "timet2" typo earlier, but xlds code looked great otherwise and I corrected for this very minor error when testing.
Here is the code I used to test whehther the run-time was output correctly from VBA:
Sub Expected_Update_Data()
Dim timet1 As Single
timet1 = Timer
ActiveSheet.Range("W2") = timet1
' Insert code here
Sheets("Expected").Activate
With Worksheets("Expected")
.Range("W1").Value = "EXPECTED macro completed at " & Format$(Now, "dd/mm/yyyy h:mmam/pm")
.Range("W3").Value = Timer
.Range("W4").Value = Range("W3") - Range("W2")
ActiveSheet.Range("A1").Select ' Finish off at EXPECTED cell A1 once macro runs completely
End Sub
In cell W5, I then manually set it to =W4/86400 and changed the format to "mm:ss.000". This gave the answer as 00:12.031 minutes (i.e. 12.031 seconds in cell W5 in the right format, as required.
The I decided to combine the above runtime calculations into one VBA line as has been discussed previously into one line as follows:
Sub Expected_Update_Data()
Dim timet1 As Single
timet1 = Timer
' Insert code here
Sheets("Expected").Activate
With Worksheets("Expected")
.Range("W1").Value = "EXPECTED macro completed at " & Format$(Now, "dd/mm/yyyy h:mmam/pm")
.Range("W3").Value = "The entire process took " & _
Format$((Timer - timet1) / 86400, "mm:ss.000") & " minutes."
End With
ActiveSheet.Range("A1").Select ' Finish off at EXPECTED cell A1 once macro runs completely
End Sub
This second code however, gives the answer as 12:16.000 minutes as opposed to 00:12.16 minutes. I'm not understanding why the Excel manual formatting produces the correctly formatted result while VBA produces a different formatted result. Any ideas as to where I may be wrong in the above?
unmarkedhelicopter, as for your cool code () of millisecond splitting, we should cover after this simple query is answered as it looks very useful indeed for more advanced run-time calcs.
Regards