I am trying to create a simple file that will help me time a race I am organizing. I found the attached file online (I forget where), and have modified it over time.
I would like to simply be able to enter numbers into column B, and have the script record the time on the same row.
The recording function works fine when I use the button, but when I type into a cell on column B, the timer stops.
I would like to simply be able to enter numbers into column B, and have the script record the time on the same row.
The recording function works fine when I use the button, but when I type into a cell on column B, the timer stops.
Option Explicit
Dim timelimit
Dim remaining
Dim stopped
Dim StartTimer
Dim BibNum
Public Sub startClock()
Dim start
start = Timer
Do While stopped = False
DoEvents
Worksheets("Timer").Range("G1").Value = Int((Timer - start + 0.5) / 60)
Worksheets("Timer").Range("H1").Value = Int((Timer - start + 0.5) / 60)
Worksheets("Timer").Range("J1").Value = (Timer - start) Mod 60
Worksheets("Timer").Range("k1").Value = (Timer - start + 0.5) - (Int(Timer - start + 0.5))
Loop
End Sub
Private Sub RecordButton_Click()
Record
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then Record
End Sub
Private Sub StartButton_Click()
startClock
End Sub
Private Sub StopButton_Click()
stopped = True
End Sub
Private Sub ResetButton_Click()
stopped = False
Worksheets("Timer").Range("G1").Value = 0
Worksheets("Timer").Range("H1").Value = 0
Worksheets("Timer").Range("J1").Value = 0
Worksheets("Timer").Range("k1").Value = 0
End Sub
Private Sub Record()
stopped = False
Dim time1 As Integer, time2 As Single, time3 As Integer, time4 As Double
Worksheets("Timer").Range("G1").Select
time1 = ActiveCell.Value
time2 = ActiveCell.Offset(0, 1).Value
time3 = ActiveCell.Offset(0, 3).Value
time4 = ActiveCell.Offset(0, 4).Value
Range("g65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = time1
ActiveCell.Offset(0, 1).Value = time2
ActiveCell.Offset(0, 3).Value = time3
ActiveCell.Offset(0, 4).Value = time4
Range("b65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Select
End Sub
Dim timelimit
Dim remaining
Dim stopped
Dim StartTimer
Dim BibNum
Public Sub startClock()
Dim start
start = Timer
Do While stopped = False
DoEvents
Worksheets("Timer").Range("G1").Value = Int((Timer - start + 0.5) / 60)
Worksheets("Timer").Range("H1").Value = Int((Timer - start + 0.5) / 60)
Worksheets("Timer").Range("J1").Value = (Timer - start) Mod 60
Worksheets("Timer").Range("k1").Value = (Timer - start + 0.5) - (Int(Timer - start + 0.5))
Loop
End Sub
Private Sub RecordButton_Click()
Record
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then Record
End Sub
Private Sub StartButton_Click()
startClock
End Sub
Private Sub StopButton_Click()
stopped = True
End Sub
Private Sub ResetButton_Click()
stopped = False
Worksheets("Timer").Range("G1").Value = 0
Worksheets("Timer").Range("H1").Value = 0
Worksheets("Timer").Range("J1").Value = 0
Worksheets("Timer").Range("k1").Value = 0
End Sub
Private Sub Record()
stopped = False
Dim time1 As Integer, time2 As Single, time3 As Integer, time4 As Double
Worksheets("Timer").Range("G1").Select
time1 = ActiveCell.Value
time2 = ActiveCell.Offset(0, 1).Value
time3 = ActiveCell.Offset(0, 3).Value
time4 = ActiveCell.Offset(0, 4).Value
Range("g65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = time1
ActiveCell.Offset(0, 1).Value = time2
ActiveCell.Offset(0, 3).Value = time3
ActiveCell.Offset(0, 4).Value = time4
Range("b65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Select
End Sub