ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Is there a way to have a timer or stopwatch function in Excel. (https://www.excelbanter.com/excel-worksheet-functions/163213-there-way-have-timer-stopwatch-function-excel.html)

JSenew

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


Otto Moehrbach

Is there a way to have a timer or stopwatch function in Excel.
 
Tell us what you want to do. HTH Otto
"JSenew" wrote in message
...




JSenew

Is there a way to have a timer or stopwatch function in Excel.
 
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.


"Otto Moehrbach" wrote:

Tell us what you want to do. HTH Otto
"JSenew" wrote in message
...





Duke Carey

Is there a way to have a timer or stopwatch function in Excel.
 
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

"Otto Moehrbach" wrote:

Tell us what you want to do. HTH Otto
"JSenew" wrote in message
...






All times are GMT +1. The time now is 12:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com