Millisecond accuracy in an Excel Timer

jbeaucaire

Well-known Member
Joined
May 8, 2002
Messages
6,012
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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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
 
Upvote 0

Forum statistics

Threads
1,214,388
Messages
6,119,227
Members
448,878
Latest member
Da9l87

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top