Hi, I have some coding that navigates through a sheet and move data from a combobox to the sheet. However, I want to add a countdown timer on an existing userform and only allow users a given amount of time to add data. Here is the timer:
And the timer is referenced here:
The code works for the first selection but than begins subtracting an additional second each time the command button is used (i.e. the first time command button is clicked, it starts counting down by 2's, then 3's etc)
I think I just need some coding to reset the countdown each time. Any help? Thanks!
Code:
Public Const nCount As Long = 60
Public nTime As Double
Public Sub RunTimer()
If nTime > 0 Then
nTime = nTime - 1
UserForm1.lblCountDown.Caption = Format(TimeSerial(0, 0, nTime), "[mm]:ss")
Application.OnTime Now + TimeSerial(0, 0, 1), "RunTimer"
Else
UserForm1.lblCountDown.ForeColor = vbRed
End If
End Sub
And the timer is referenced here:
Code:
Private Sub CommandButton1_Click()
nTime = ncount
Call RunTimer
ActiveCell.Value = Me.txt1.Value & "-" & Me.cbo1.Value
If ActiveCell.Row Mod 2 = 1 Then
If ActiveCell.Column = 3 Then
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(0, -1).Select
End If
Else
If ActiveCell.Column = 14 Then
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(0, 1).Select
End If
End If
Me.cbo1.Value = vbNullString
Me.txt2.Value = vbNullString
Me.txt3.Value = vbNullString
Me.txt4.Value = vbNullString
End Sub
The code works for the first selection but than begins subtracting an additional second each time the command button is used (i.e. the first time command button is clicked, it starts counting down by 2's, then 3's etc)
I think I just need some coding to reset the countdown each time. Any help? Thanks!