![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 07:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com