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:

  1. Option Explicit
  2. Public Sub WaitExample()
  3. 'code with functionality goes here. At this point, 5 sec wait is introduced.
  4. Application.Wait (Now + TimeValue("00:00:05"))
  5. code with functionality goes here.
  6. 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".

 

You can find similar Excel Questions and Answer hereunder

1) How can I avoid updates to cell values during macro execution?

2) Converting numbers stored as text to numbers via macro in Excel

3) Calling a macro from another workbook in Excel

4) How do I assign a macro to a shape using VBA?

5) How can I clear cell after activating a routine when there is a change in value of a cell?

6) I frequently use a Macro - is there a way to quickly access the Macro using a Keyboard Shortcut?

7) How can I prevent users from seeing / accessing my macro code?

8) How can I see where page breaks occur before actually printing?

9) I have a macro that takes a lot of time for execution - how can I keep the user informed that the macro is running?

10) How can I add a Timestamp after macro execution?

11) I frequently use a Macro - is there a way to quickly access the Macro in the Excel Ribbon?

12) After several iterations, I have finalized my WorkBook - how do I make it Read-only from then on to prevent further edits?

13) How can I activate a routine when there is a change in value of a cell?

14) How can I execute an event at a predetermined time from my Macro?

15) I want to automatically run a procedure whenever I close my WorkBook so that it is in a known state - how can I achieve that?