# Millisecond accuracy in an Excel Timer

#### jbeaucaire

##### Well-known Member
Take a look at this sample sheet.

LapCounter.xls
In it I've developed some lap timers for tracking runners. However to be truly useful, each time I press a LAP button on any one row it really needs to record time with millisecond accuracy, which it currently does not.

Any help would be appreciated.

### Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

#### jbeaucaire

##### Well-known Member
SHG on ExcelTip.com has found a technique I can use. Download the file again to see the working solution.

Code:
``````Option Explicit

Public Time1 As Double, Time2 As Double
Public Next1 As Long, Next2 As Long
Private Declare Function GetTickCount Lib "Kernel32" () As Long

Sub StartAll()
Range("B2:H3").ClearContents
Time1 = GetTickCount()
Time2 = GetTickCount()
Next1 = 2
Next2 = 2
End Sub

Sub Start1()
Range("B2:H2").ClearContents
Time1 = GetTickCount()
Next1 = 2
End Sub

Sub Lap1()
If Next1 < 9 Then
Cells(2, Next1) = Int(GetTickCount() - Time1) / 86400 / 1000
Time1 = GetTickCount()
Next1 = Next1 + 1
End If
End Sub

Sub Start2()
Range("B3:H3").ClearContents
Time2 = GetTickCount()
Next2 = 2
End Sub

Sub Lap2()
If Next2 < 9 Then
Cells(3, Next2) = Int(GetTickCount() - Time2) / 86400 / 1000
Time2 = GetTickCount()
Next2 = Next2 + 1
End If
End Sub``````
LapCounter.xls