'之一 Sub Sample() Range( "b2" ) = "=now()" If Range( "b2" ) >= Range( "c2" ) Then MsgBox "時間到" Exit Sub End If Call StartTime End Sub Sub StartTime() Application.OnTime Now + TimeSerial(0, 0, 1), "Sample" End Sub
'之二 Sub Sample() Do While range( "d2" ) > Now '活動時間未過期即不斷迴圈 Application.Wait Now + TimeSerial(0, 0, -1) '控制時間 Application.Calculate '計算工作表 Loop MsgBox "時間到!" End Sub