
Option Explicit
'// Displays on a worksheet the Elapsed time in mmsecs
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Public bStart As Boolean
Public iStartTime As Long
Public iEndTime As Long
Public iTotalTime As Long
Public Sub StartStop_MyTimer()
'// Press button to START
'// Press button again to STOP
bStart = Not (bStart)
If bStart Then
iStartTime = timeGetTime
Else
iEndTime = timeGetTime
iTotalTime = iEndTime - iStartTime
With Sheets("Sheet1").Range("A65536").End(xlUp).Offset(1, 0)
.Value = iTotalTime
.Offset(0, 1).Value = "milliseconds"
End With
End If
End Sub