Hello,
This (see below) is an example of the use of Application.OnTime RunTime.
It is supposed the wait for 10 seconds and increment sheet1.cells(1,1).value by 15.
It does not. What am I missing?
Once it works with "00:00:10", I was hoping to replace "00:00:10" by a string that is the result of the concatenation of h:m:s that a user could input. Is this possible? Do I need to add chr$(34) at the beginning and the end? i.e. is aa going to work as is or aa=chr$(34)+aa+chr$(34)?
Please advise
Thank you
CODE ------------------------------START------------------------
Public Sub test_run_time()
Debug.Print Now
Call TestMacroAutoRun(0, 0, 10)
Debug.Print Now
End Sub
Sub TestMacroAutoRun(h, m, s)
Dim RunTime As Date
Dim aa As Date
hh = conv(h)
mm = conv(m)
ss = conv(s)
aa = hh + ":" + mm + ":" + ss
RunTime = Now + TimeValue("00:00:10")
Application.OnTime RunTime, "zipi"
Debug.Print aa
Application.OnTime RunTime, "zipi", , False
End Sub
Public Function conv(h) As String
If h < 10 Then
conv = "0" + LTrim(RTrim(Str$(h)))
Else
conv = LTrim(RTrim(Str$(h)))
End If
If h = 0 Then
conv = "00"
End If
End Function
Sub zipi()
Sheet1.Cells(1, 1).Value = Sheet1.Cells(1, 1).Value + 15
End Sub
CODE---------------------- STOP ---------------------------------
Bookmarks