How to detect if a macro is in the middle of running

  • Thread starter Thread starter RocketMan
  • Start date Start date
R

RocketMan

I am required to have two different ways to activate the same macro:
from a button on a sheet and when the form is opened and a certain
field has 'auto' in it. I also realized that someone might just click
the button twice. I'd like to be able to check to see if a macro is
already working if the same macro is selected again.

How can I do this?
 
You could put in

Application.Statusbar = "Macro running"

when you start running the macro. It will put a comment in the Lower LH
corner of the window. To turn if off use

Application.StatusBar = FALSE

HTH,
Barb Reinhardt
 
Normally the only time someone could start your code a second time would be
if you have a modeless form showing and nothing else going on. Though in
long routines with DoEvents could allow the button to call your macro, or
some event triggered by your code in turn attempting to re-run your app.

You could set a global boolean flag and exit your code if it's true, and of
course set it false when all done.

Public gbAppRunning as Boolean

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top