Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

VBA-Excel: Application.Wait OR Wait Method

Description:

The Application.Wait () func­tion pauses the run­ning code or macro for the time spec­i­fied and once that time is passed, it returns True value.

Format:

Expression.Wait (Time)

  • Expres­sion : A vari­able that rep­re­sents an Appli­ca­tion Object.
  • The Wait method stops all the Microsoft Excel activ­i­ties and pre­vent all the major operations.
Arguments:
  • Time
    • Manda­tory
    • Type:Variant
    • The time at which macro to be resumed and returns True

Example1: Wait Till Spec­i­fied Time.

Application.Wait “15:30:30”

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

Example2: Wait For The Par­tic­u­lar 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.

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: