ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to stop other macros while current macro runs (https://www.excelbanter.com/excel-programming/359590-how-stop-other-macros-while-current-macro-runs.html)

Paul987[_23_]

How to stop other macros while current macro runs
 

I have several macros running, and occasionally it seems that one won't
finish because another has placed a value it wasn't expecting and
generates an error. Is there code I can place in the begining that
will halt all other macros, then turn them back on at the end?

On another note, does anyone know a good link that goes over some of
the basics of VBA? I could use a course on the basics. THanks

-Paul


--
Paul987
------------------------------------------------------------------------
Paul987's Profile: http://www.excelforum.com/member.php...o&userid=24850
View this thread: http://www.excelforum.com/showthread...hreadid=535505


tony h[_101_]

How to stop other macros while current macro runs
 

If you put error trapping in your code (there are plenty of posts on
this subject) when the error occurs control will pass to the error
handling code rather than just crashing.

HAve a look in this forum and in the help files. If you get stuck post
again.

Things to look for:
- on error goto label
err.number
err.description
resume label

have fun


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=535505


K Dales[_2_]

How to stop other macros while current macro runs
 
In general, macros run sequentially, not concurrently - that is, they run one
at a time and if they call another, they pause until the one that was called
returns its result (there are exceptions, like the OnTime procedure and
certain event procedures, but I doubt that is what you have). So I don't
think it is a matter of timing between macros. It is the fact that you are
getting unexpected results. Good code has to be able to anticipate problems
and possible "bad" input so it does not crash with an error. But it is part
of the learning curve we all go through.

The best thing to do is learn how to use the debug functions in the VBA
editor, especially how to step through code and test the values of your
variables along the way. A look in the VBA editor help file will give you
some info - and a good book on learning vba - there are many out there.
--
- K Dales


"Paul987" wrote:


I have several macros running, and occasionally it seems that one won't
finish because another has placed a value it wasn't expecting and
generates an error. Is there code I can place in the begining that
will halt all other macros, then turn them back on at the end?

On another note, does anyone know a good link that goes over some of
the basics of VBA? I could use a course on the basics. THanks

-Paul


--
Paul987
------------------------------------------------------------------------
Paul987's Profile: http://www.excelforum.com/member.php...o&userid=24850
View this thread: http://www.excelforum.com/showthread...hreadid=535505




All times are GMT +1. The time now is 10:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com