Even more wait for Gane of thrones New Season??? Noooo !!! Who in real life would like to wait… especially for Game Of Thrones 😀 No one would like to wait for any thing in real life
Sometimes, while doing Automation in Excel Macro we require a “Wait” or “Sleep” function, which will hold the execution of the next statements until the specified time.
Following is the Syntax, of Wait function in Excel VBA (Macro):
Here Time should be in this format : HH:MM:SS
Below code will pause the Macro running till 1:45 PM
Now if want to pause the Macro for few hours, minutes or seconds then we can use DateAdd() Function in Application.Wait function.
|Application.Wait DateAdd(“s”, 3, Now)|
In the above example, Macro will be paused for 3 Seconds.
For 3 minutes:
|Application.Wait DateAdd(“n”, 3, Now)|
Note: For Minute we should use “n” not “m”. “m” is for Month. For more details click here
Similarly for 3 hrs:
|Application.Wait DateAdd(“h”, 3, Now)|
My name is Vishwamitra Mishra. Friends Call me Vishwa. This blog is authored by me. I am an Excel Geek. Well, this blog talks a lot about my passion in Excels & Macros so I’ll not talk about it :) I am very much passionate about traveling & quite recently discovered that I am a good photographer too..:P
AND GET A FREE!
E-BOOK FOR EXCEL VBA BEGINNERS
DON'T MISS ANY NEW ARTICLE !
Get your FREE! E-Book & Have Every New Article Delivered Straight To Your Email-Box