Excel VBA Application.Wait 方法 类似sleep
时间:2018-06-19 23:26:40
收藏:0
阅读:3122
1.本事例时间到六点时就弹出Msgbox。
Sub test01() If Application.Wait("6:00:00") Then MsgBox "现在时刻六点整" '这是系统时间 End If End Sub
2.执行完这个宏10秒之后弹出Msgbox。
Sub test02() newHour = Hour(Now()) newMinute = Minute(Now()) newSecond = Second(Now()) + 10 waitTime = TimeSerial(newHour, newMinute, newSecond) If Application.Wait waitTime Then MsgBox "时间过去了10秒" End If End Sub
3.执行完这个宏10秒之后弹出Msgbox。
sub test03() If Application.Wait(Now + TimeValue("0:00:10")) Then '感觉比test02简单些 MsgBox "时间过去了10秒" End If End Sub
评论(0)