Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Timer Question

I have an Excel Program that analyses and interprests the results of event
times within a certain sport - from these, conclusions about performance can
be interpreted. I time the sport with a stop watch with split lap counter
and enter these times (about 20 of them) post race manually into my
spreadsheet. My question is whether it is possible to construct the same
programme but incorporate a 'stopwatch' element into the programme. In other
words I would key the computer as a stop watch and these transitions would
be automatically entered into my programme. Sounds complicated, but if
possible can someone point me in the right direction please

Adrian


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Timer Question

Go to the VB editor (Alt + F11)
Right-click a sheet in the workbook and do View code.
In the right-hand worksheet code module put all this:

Option Explicit
Private lStartTime As Long
Private lEndTime As Long
Private Declare Function timeGetTime Lib "winmm.dll" () As Long

Sub StartSW()
lStartTime = timeGetTime()
End Sub

Sub StopSW()
lEndTime = timeGetTime()
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count 1 Then
Exit Sub
End If
If Target.Row = 1 Then
StartSW
Else
StopSW
Target.Value = (lEndTime - lStartTime) / 1000
End If
End Sub

The timer will start by selecting any cell in row 1.
Then to get the next timer press the arrow down key.
Once you are out of row 1 you can press the arrow right key if you want.
Adjust the code as needed.
Not sure it will be as precise as your stopwatch though, but for your
purpose it may precise enough.


RBS


"Adrian Moore" wrote in message
. ..
I have an Excel Program that analyses and interprests the results of event
times within a certain sport - from these, conclusions about performance
can be interpreted. I time the sport with a stop watch with split lap
counter and enter these times (about 20 of them) post race manually into my
spreadsheet. My question is whether it is possible to construct the same
programme but incorporate a 'stopwatch' element into the programme. In
other words I would key the computer as a stop watch and these transitions
would be automatically entered into my programme. Sounds complicated, but
if possible can someone point me in the right direction please

Adrian


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Timer Question

To have the option to stop you could do this:

Option Explicit
Private lStartTime As Long
Private lEndTime As Long
Private bStop As Boolean
Private Declare Function timeGetTime Lib "winmm.dll" () As Long

Sub StartSW()
lStartTime = timeGetTime()
End Sub

Sub StopSW()
lEndTime = timeGetTime()
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Cells.Count 1 Then
bStop = True
Exit Sub
End If

'or you could do he
'If Target.Row = 1 And Target.Column = 1 Then
If Target.Row = 1 Then
bStop = False
StartSW
Else
If bStop = False Then
StopSW
Target.Value = (lEndTime - lStartTime) / 1000
End If
End If

End Sub


RBS


"Adrian Moore" wrote in message
. ..
I have an Excel Program that analyses and interprests the results of event
times within a certain sport - from these, conclusions about performance
can be interpreted. I time the sport with a stop watch with split lap
counter and enter these times (about 20 of them) post race manually into my
spreadsheet. My question is whether it is possible to construct the same
programme but incorporate a 'stopwatch' element into the programme. In
other words I would key the computer as a stop watch and these transitions
would be automatically entered into my programme. Sounds complicated, but
if possible can someone point me in the right direction please

Adrian


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Timer question teepee[_3_] Excel Discussion (Misc queries) 3 December 26th 08 07:23 PM
Timer in VBA peyman Excel Discussion (Misc queries) 2 October 5th 07 06:53 PM
Stopping a Timer / Running a timer simultaneously on Excel Paul23 Excel Discussion (Misc queries) 1 March 10th 06 12:08 PM
Timer TJ Excel Programming 1 July 9th 04 03:18 PM
need help with a timer ionaman Excel Programming 0 April 13th 04 08:40 PM


All times are GMT +1. The time now is 11:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"