Skip to content

Latest commit

 

History

History
72 lines (44 loc) · 1.56 KB

Excel.Application.Wait.md

File metadata and controls

72 lines (44 loc) · 1.56 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Application.Wait method (Excel)
vbaxl10.chm133242
vbaxl10.chm133242
Excel.Application.Wait
71425d1c-6b37-a510-d8b5-072136e98f04
04/05/2019
high

Application.Wait method (Excel)

Pauses a running macro until a specified time. Returns True if the specified time has arrived.

Syntax

expression.Wait (Time)

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
Time Required Variant The time at which you want the macro to resume, in Microsoft Excel date format.

Return value

Boolean

Remarks

The Wait method suspends all Microsoft Excel activity and may prevent you from performing other operations on your computer while Wait is in effect. However, background processes such as printing and recalculation continue.

Example

This example pauses a running macro until 6:23 P.M. today.

Application.Wait "18:23:00"

This example pauses a running macro for approximately 10 seconds.

newHour = Hour(Now()) 
newMinute = Minute(Now()) 
newSecond = Second(Now()) + 10 
waitTime = TimeSerial(newHour, newMinute, newSecond) 
Application.Wait waitTime

This example displays a message indicating whether 10 seconds have passed.

If Application.Wait(Now + TimeValue("0:00:10")) Then 
 MsgBox "Time expired" 
End If

[!includeSupport and feedback]