在模塊中添加,B、C列設(shè)置格式為 hh:mm:ss Sub sTime() '每隔一秒鐘調(diào)整本程序自身一次。 '增加D列,標記倒記時是否完成, '添加新的倒計時,更改B列數(shù)據(jù),刪除對應(yīng)C列、D列數(shù)據(jù)。 Application.OnTime Now + TimeValue("00:00:01"), "sTime" For i = 2 To 14 If Cells(i, 3) > 0 Then Cells(i, 3) = Cells(i, 3) - TimeValue("00:00:01") If Cells(i, 3) = TimeValue("00:00:10") Then '10秒倒記時,改變顏色,提示音,加在這兒,不另寫了。 End If Else If Cells(i, 3) = TimeValue("00:00:00") And Cells(i, 4) = "" And Len(Cells(i, 3)) > 0 Then Cells(i, 4) = "時間到" Else If Cells(i, 3) = 0 And Cells(i, 4) = "" Then Cells(i, 3) = Cells(i, 2) End If End If Next i End Sub 然后在工作表中添加一個按鈕,調(diào)用: Private Sub CommandButton1_Click() Call sTime End Sub |
|