In Excel VBA, I want to push a button, run some code, and while the code is running have a form window appear saying something like "Code is running, please wait until finished. Click stop button to terminate code."
But every time I .Show a form the code stops, waiting for the form window to be closed before continuing. Is there a way to force the code to continue to run while the form window is open? Thanks!
Answered: Add (False) at the end of .Show or change the form's ShowModal property to False. Then add Application.Wait (Now + TimeValue("0:00:01")) just after fmRunning.Show(False). Or insert "DoEvents" instead of the Application.Wait Thanks all!!
You need to set the userform to be modeless. This can be done two ways:
Userform.Show vbModeless
See MSDN for more info.
Using only Userform.Show vbModeless
can cause blank form.
You should also use the command Userform.Repaint
. This will refresh the info on the form. Example:
Userform.Show vbModeless
Userform.Caption = "Some text" 'change the Caption text
Userform.Repaint 'refresh changes
This way you should see the changes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With