still not working and in the vba editor these lines are red font
nextTime = Now + TimeSerial(0,0,2), "repeatit"
Private nextTime As Date
Private lastTime As Date
Sub startit()
MsgBox Now & " startit"
lastTime = Now
nextTime = Now + TimeSerial(0, 0, 2)
Application.OnTime nextTime, "repeatit"
End Sub
Sub repeatit()
MsgBox lastTime & vbNewLine & Now & " repeatit"
' do whatever you need here to "refresh the links"; perhaps:
' Application.Calculate
' then...
lastTime = Now
nextTime = Now + TimeSerial(0, 0, 2)
Application.OnTime nextTime, "repeatit"
End Sub
Sub stoptit()
On Error Resume Next
MsgBox lastTime & vbNewLine & Now & " stopit"
Application.OnTime nextTime, "repeatit", , False
End Sub
Private Declare PtrSafe Sub Sleep Lib "kernel32.dll" ( _
ByVal dwMilliseconds As Long)
Public Sub mySleep()
do
'your code
Call Sleep(2000) '2000 Millisekunden Pause
loop
End Sub
Hi,
is the problem to build a loop?
Code:Private Declare PtrSafe Sub Sleep Lib "kernel32.dll" ( _ ByVal dwMilliseconds As Long) Public Sub mySleep() do 'your code Call Sleep(2000) '2000 Millisekunden Pause loop End Sub
The application.wait should work as well.
regards
Hi fennek - thanks this seems to work as I see the calculate work - I start the code by a shortcut ctrl+z
the way I can exit the code is pressing escape then end !