Reputation: 1147
I have created a simple userform with a text label. I have put this code on activation of userform to run remaining time from target time. It is good once it runs, but it does not count down... Seconds do not flick down ... etc.
Code
Private Sub UserForm_activate()
targtime = DateValue("28 Jun 2018") + TimeValue("18:37:00")
remtime = targtime - Now
Me.Label1 = Int(remtime) & " Days " & Format(remtime - Int(remtime), "HH:MM:SS")
End Sub
What am I doing wrong?
Upvotes: 1
Views: 419
Reputation: 43585
Put it in an endless loop and it would start ticking every second:
Private Sub UserForm_Activate()
Dim remTime As Date
While True
remTime = DateValue("28 Jun 2018") + TimeValue("18:37:00") - Now
Me.Label1 = Int(remTime) & " Days " & Format(remTime - Int(remTime), "HH:MM:SS")
Me.Repaint
Application.Wait Now + #12:00:01 AM#
Wend
End Sub
Upvotes: 1