Consulting

Results 1 to 5 of 5

Thread: display a "Please Wait" box while calculating

  1. #1
    VBAX Regular
    Joined
    Jul 2008
    Posts
    41
    Location

    Solved: display a "Please Wait" box while calculating

    I must be missing something simple... How do I show a generic userform (captioned "please wait while I calculate this") before I begin calculation and then unload it when calculation is finished. The problem is the userform takes focus and my calculation won't start until I close the form. I'm trying to avoid putting the calculation code *in* the userform, because then I'd have to have a different form each instance I need this.

    Multithreading is new to me. Many thanks for any advice.
    Last edited by dlh; 10-30-2008 at 10:17 AM.

  2. #2
    I call the show method of the form with 0 as a parameter, making it modeless (I believe) so it'll show the form and then your macro will keep running, then you can just unload/hide the form once you're done calculating

  3. #3
    VBAX Regular
    Joined
    Jul 2008
    Posts
    41
    Location
    Thank you, jfournier. Almost works. The code now runs, but the interior of the userform window is never drawn.

    [vba]
    PopupWait.Show (0)
    [/vba]

  4. #4
    you may need to call DoEvents during your code to get the form to update. I usually do this at the beginning or end of a loop. Using DoEvents allows you to process userform control events, like hitting a cancel button, to stop your processing...

  5. #5
    VBAX Regular
    Joined
    Jul 2008
    Posts
    41
    Location
    Thank you very much. It works as intended.

    Am I correct in understanding that if I have set Application.EnableEvents to FALSE, then DoEvents will only allow predefined application events to run, not user-defined events like Worksheet_Change?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •