Be the first user to complete this post

  • 0
Add to List

VBA-Excel: Application.Wait OR Wait Method


The Application.Wait () function pauses the running code or macro for the time specified and once that time is passed, it returns True value.


Expression.Wait (Time)

  • Expression : A variable that represents an Application Object.
  • The Wait method stops all the Microsoft Excel activities and prevent all the major operations.
  • Time
    • Manda­tory
    • Type:Variant
    • The time at which macro to be resumed and returns True

Example1: Wait Till Specified Time.

Application.Wait “15:30:30”

The above code pauses the macro till 15:30:30 today.

Example2: Wait For The Particular Time Interval

Function FnWait(intTime)

    newHour = Hour(Now())

    newMinute = Minute(Now())

    newSecond = Second(Now()) + intTime

     waitTime = TimeSerial(newHour, newMinute, newSecond)

 Application.Wait waitTime

End Function
Call FnWait(10)

This function pauses the macro for 10 seconds.

Also Read:

  1. VBA-Excel: Consolidator – Merge or Combine Multiple Excel Files Into One
  2. VBA-Excel: Create a WorkBook at Runtime.
  3. VBA-Excel: Copy/Paste data - Copy the Entire data from one sheet to another
  4. Add Tools to Quick Access Tool Bar(Excel Top Bar)
  5. VBA-Excel: Delete Blank Rows from Excel Work Sheet
  6. VBA Excel - Cells, Ranges and Offset: Refer to Cells by Using Shortcut Notation
  7. VBA-Excel: Fill Excel Range Values in a 2D Array
  8. VBA Codes - Record Macro