title: DoEvents doesn't do the events... Why?
body: <p>I'm using <code>DoEvents</code> to force an update of a progress indicator in the status bar (or in some cell in the sheet) as in the example code below. But the screen doesn't refresh, or stops refreshing at some point. The task eventually completes but the progress bar is useless.</p>
  
  <p>Why won't <code>DoEvents</code> "do the events"? What else can I do to force a screen update?</p>
  
  <p>Edit: I'm using Excel 2003 on Windows XP.</p>
  
  <p>This is a follow up to an <a href="https://stackoverflow.com/questions/3735378/how-do-i-force-a-screen-update-in-excel-vba">earlier question</a>; thanks to <a href="https://stackoverflow.com/users/5050/robert-mearns">Robert Mearns</a> for his answer and the sample code below. </p>
  
  <pre><code>Sub ProgressMeter()
  
  Dim booStatusBarState As Boolean
  Dim iMax As Integer
  Dim i As Integer
  
  iMax = 100
  
      Application.ScreenUpdating = False
  ''//Turn off screen updating
  
      booStatusBarState = Application.DisplayStatusBar
  ''//Get the statusbar display setting
  
      Application.DisplayStatusBar = True
  ''//Make sure that the statusbar is visible
  
      For i = 1 To iMax ''// imax is usually 30 or so
          fractionDone = CDbl(i) / CDbl(iMax)
          Application.StatusBar = Format(fractionDone, "0%") &amp; " done..."
          ''// or, alternatively:
          ''// statusRange.value = Format(fractionDone, "0%") &amp; " done..."
  
          ''// Some code.......
  
          DoEvents
          ''//Yield Control
  
      Next i
  
      Application.DisplayStatusBar = booStatusBarState
  ''//Reset Status bar display setting
  
      Application.StatusBar = False
  ''//Return control of the Status bar to Excel
  
      Application.ScreenUpdating = True
  ''//Turn on screen updating
  
  End Sub
  </code></pre>