Stop and Wait While Executing VBA Code

Stop and Wait While Executing VBA Code

This programs stops and waits for a few seconds in the middle of the execution of the VBA code.


Sometimes it is useful to stop the coding for a few seconds due to processes that needs to be finalized that are not directly connected and in interaction with the VBA engine, thus will make the program crash if they are not finalized before executing the rest of the VBA program. For example if you have a program that you can execute through VBA macro but it is not fully integrated with excel thus you do not know when the other program has performed their processes. But you might know that the maximum time for finish is 10 seconds then you simply stop your VBA code for 10 seconds and then you can continue the code again!

An example file of the code is possible to download at the end of this web site, enjoy! Or just copy and paste the code directly from this page.



Public Sub

‘Stops the execution of the code and continues after 10 seconds.
 Application.Wait Now + TimeValue("00:00:10")

End sub




Download excel file! Stop_and_Wait_While_Executing_VBA_Code.xls


its very interesting topic

Comment made by: madhu , 2010-04-08 09:10:42

its very interesting area..its has gud future

Comment made by: madhu , 2010-04-08 09:13:09

Application.Wait Now + TimeValue("00:00:10")

Comment made by: DON , 2012-03-03 18:37:05

Option Explicit Public Run As Boolean If Run Then Run = False End End If Run = True

Comment made by: Jacky , 2012-10-26 06:57:13

It is really helpful Thanks a ton

Comment made by: Atul Mishra , 2013-02-17 06:45:51

Write Comment:


two + 3 minus 1=

Your name: