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)|