在模块中添加,B、C列设置格式为 hh:mm:ss Sub sTime() '每隔一秒钟调整本程序自身一次。 '增加D列,标记倒记时是否完成, '添加新的倒计时,更改B列数据,删除对应C列、D列数据。 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 然后在工作表中添加一个按钮,调用: Private Sub CommandButton1_Click() Call sTime End Sub |
|