I want to generate a 30 seconds delay in vba. I can’t use ‘Timer’ as my application will run overnight till next morning. (Timer will generate the seconds(in fraction) elapsed till midnight). Is there any other way to achieve this other than Timer and Application.WaitNow().
I tried using the following code but it throws Code execution has been interrupted error.
Function Wait()
Dim StartSecond
Dim EndSecond
StartSecond = Second(Now)
'Sheets("SampleOutputEx").Range("M2") = StartSecond
EndSecond = (StartSecond + 30) Mod 60
While Second(Now) <> EndSecond
DoEvents
Wend
End Function
Here we go. Never thought the answer could be very simple.
This works fine for me. Any comments regarding this are much appreciated.