Silver
11-10-2016, 09:06 PM
Hi,
I came across a code that displays current time in userform textbox.
Below is the code -
Userform Code
Option Explicit
Private Sub CommandButton1_Click()
Application.Run "StopTimer"
Unload Me
End Sub
Private Sub UserForm_Activate()
Application.Run "StartTimer"
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
StopTimer
End Sub
In a Module
Option ExplicitDim T
Sub StopTimer()
On Error Resume Next
Application.OnTime T, Procedure:="Update", Schedule:=False
End Sub
Sub StartTimer()
T = Now + TimeValue("00:00:01")
Application.OnTime T, "Update"
End Sub
Sub Update()
UserForm1.TextBox1.Value = Format(Now, "hh:mm:ss")
Call StartTimer
End Sub
How do I get the code to deduct 05 Hrs and 30 Mins and then display the time.
Have attached test workbook for reference.
Any assistance will be appreciated.
I came across a code that displays current time in userform textbox.
Below is the code -
Userform Code
Option Explicit
Private Sub CommandButton1_Click()
Application.Run "StopTimer"
Unload Me
End Sub
Private Sub UserForm_Activate()
Application.Run "StartTimer"
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
StopTimer
End Sub
In a Module
Option ExplicitDim T
Sub StopTimer()
On Error Resume Next
Application.OnTime T, Procedure:="Update", Schedule:=False
End Sub
Sub StartTimer()
T = Now + TimeValue("00:00:01")
Application.OnTime T, "Update"
End Sub
Sub Update()
UserForm1.TextBox1.Value = Format(Now, "hh:mm:ss")
Call StartTimer
End Sub
How do I get the code to deduct 05 Hrs and 30 Mins and then display the time.
Have attached test workbook for reference.
Any assistance will be appreciated.