I have an Excel worksheet that has the following macro. I'd like to loop it every second but danged if I can find the function to do that. Isn't it possible?
Sub Macro1() ' ' Macro1 Macro ' Do Calculate 'Here I want to wait for one second Loop End Sub
You can also use the following: Application. Wait (Now + TimeValue("00:00:05")). This forces your macro to wait 5 seconds, before it continues with the next line of code.
Wait method only accepts one argument: time. To wait 5 seconds, like I did in the demo above, you feed Application. Wait the current time with the Now function. Then, you use the TimeValue function to add 5 seconds to the current time.
First, use the keyword “Application” and type a dot (.) to get the list of properties and methods. After that, select or type the “Wait” method. Now, specify the “Time” argument to tell VBA that how much time you want to wait. In the end, run the code to put wait for all the activities in Excel.
VBA Sleep function is a windows function present under windows DLL files which is used to stop or pause the macro procedure from running for a specified amount of time after that certain amount of we can resume the program.
Use the Wait method:
Application.Wait Now + #0:00:01#
or (for Excel 2010 and later):
Application.Wait Now + #12:00:01 AM#
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With