make a macro wait before next command in Excel
Q143. In Excel, how can I make my macro wait for 5 secs before executing the next command?
To do it in Excel, here is the answer:
- Option Explicit
- Public Sub WaitExample()
- 'code with functionality goes here. At this point, 5 sec wait is introduced.
- Application.Wait (Now + TimeValue("00:00:05"))
- code with functionality goes here.
- End Sub
a) The TimeValue argument is of the format "hh:mm:ss". So to introduce a 1 min wait, the argument becomes "00:01:00".