Is there a way to have a timer or stopwatch function in Excel.

  • Thread starter Thread starter Guest
  • Start date Start date
Wishing to help a friend of mine that runs mtn. bike races. He does in
manually, I was wondering if I could use Excel. The dream would be I 'start'
the timer, then as a racer crosses the finish line, I type in their bib
number and hit enter. Time is recorded for that bib number. When the next
racer finishes, I type in that bib number and hit enter. That time is
recorded for that bib number.

Thanks in advance for you help.
 
Here's some great code for a precise timer.


Private Declare Function getFrequency Lib "kernel32" Alias _
"QueryPerformanceFrequency" (cyFrequency As Currency) As Long
Private Declare Function getTickCount Lib "kernel32" Alias _
"QueryPerformanceCounter" (cyTickCount As Currency) As Long

Public dblStart As Double
Public dblEnd As Double


Function MicroTimer() As Double
' COPYRIGHT © DECISION MODELS LIMITED 2000. All rights reserved
' returns a Double containing seconds
' uses Windows API calls to the high resolution timer

Dim cyTicks1 As Currency
Static cyFrequency As Currency

MicroTimer = 0
' get frequency
If cyFrequency = 0 Then getFrequency cyFrequency

' get ticks
getTickCount cyTicks1

' calc seconds
If cyFrequency Then MicroTimer = cyTicks1 / cyFrequency

End Function

-----------------
In your code declare a couple of vars that are doubles

Public dblStart As Double
Public dblEnd As Double

'record the start time
dblStart = MicroTimer()

' do some stuff here

' record the end time
dblEnd = MicroTimer()

' calc the elapsed time & put in the range named "Elapsed"
Range("elapsed) = dblEnd - dblStart
 
Back
Top