title: How to get 30 seconds delay
body: <p>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().<br>
  I tried using the following code but it throws Code execution has been interrupted error.</p>
  
  <pre><code>Function Wait()
  
  Dim StartSecond
  Dim EndSecond
  
  StartSecond = Second(Now)
  'Sheets("SampleOutputEx").Range("M2") = StartSecond
  
  EndSecond = (StartSecond + 30) Mod 60                             
  While Second(Now) &lt;&gt; EndSecond
    DoEvents
  Wend
  
  End Function
  </code></pre>