22. VBA Tips - Pause Code

Nick's picture

This VBA tip is about how to pause code.

  • There are many reasons why you might want to pause code:
    • You might be waiting for a file to arrive and need to pause before rechecking
    • Maybe you've launched a batch file and it needs 3 seconds to run before you can continue

This is the code we'll use for this tip:



  1. We recreate a new time using the TimeSerial function
  2. The inputs are: hour, minute and second
  3. We retrieve the current hour, minute and second, then add a certain amount of seconds that we pick up from the spreadhseet (for demo purposes)
  4. We then ask the application to wait until the time we input
  5. Download the practise sheet, and press the button for a demo
  6. You can change the time to wait as long or as little as you want down to 1 second

Download sheet to practise how to Pause Code in Excel

Training Video on how to Pause Code in Excel:

pause-code.xls848.5 KB