点击按钮后倒计时

时间:2016-02-23 18:35:09

标签: vba excel-vba countdown excel

我想进行倒计时,因此我设置了一个时区格式的单元格E1,并将0:02:55作为开始时间。之后我尝试使用此代码单击按钮后进行coutdown,但出现错误,它不可运行。

Sub Timer()
Dim gCount As Date
gCount = Now + TimeValue("00:00:01")
Application.OnTime gCount, "ResetTime"
End Sub

Sub ResetTime()
Dim xRng As Range
Set xRng = Application.ActiveSheet.Range("E1")
xRng.Value = xRng.Value - TimeSerial(0, 0, 1)
If xRng.Value <= 0 Then
    MsgBox "Countdown complete."
    Exit Sub
End If
Call Timer
End Sub

0 个答案:

没有答案