Is there a way I can display a message while a macro runs in the background?
I want to let users know to wait until the macro finishes. I tried the
msgbox command but the macro will not run until you press ok and I want it to
stay open until the macro finishes. Any ideas?
Excel is only single threaded, so you can only have one thing going on
at a time, but to accomplish what you want you could add a user form
to your project. Then you macro could have the following code:
Sub warningMacro()
Load UserForm1
UserForm1.Show
End Sub
In your form, you would have the following event which automatically
starts running when the form is activated and does all your
calculations. When it is done, you just close the form.
Private Sub UserForm_Activate()
'Do whatever you need to do here. For example, wait for 10
seconds. (You have to add a label to the form for this to work)
UserForm1.Label1.Caption = "hi"
startTime = Timer
Do
DoEvents
UserForm1.Label1.Caption = (Timer - startTime)
Loop While Timer < startTime + 10
'when you are done, close the form
Unload UserForm1
End Sub
Maybe this will work for you.