title: Excel/VBA DoEvents and control return
body: <p>I am trying to make a macro that returns at least some partial control to the user when it runs. The macro behavior cannot be changed dangerously if the user edits cells, as there is few dependent content.</p>
  
  <p>I am using this method to allow the user to occupy the execution thread and commit their cell changes before the macro gains control back and proceeds to the next statement:</p>
  
  <pre><code>Sub retCtrl(Optional ms As Long = 350)
  Dim l As Long: l = Timer
  Do While Timer - l &lt; (0# + ms / 1000)
      DoEvents
  Loop
  End Sub
  </code></pre>
  
  <p>I put this after some long statements and inside loops.</p>
  
  <p>It's choppy, but functional, <strong>with only one problem:
  if the user takes to long to edit the cell, the macro silently stops.</strong></p>
  
  <p>Can anyone explain why this happens? Is it because the timer elapses the threshold? I thought all macro execution stops when the workbook is in edit mode?</p>
  
  <p>Any advice on how to handle this otherwise?</p>