按alt+F11键,打开VBA窗口,双击sheet1,将下方的代码复制到打开的窗口中;
Sub 倒计时()
[a1]
.NumberFormatLocal
= "h:mm:ss;@"[a1] = [a1] - 1 / 3600 / 24
If [a1] < 1 / 60 / 24 Then
[a1]
.Font.ColorIndex
= 3Else
[a1]
.Font.ColorIndex
= 5End If
If [a1] > 0 Then
Application.OnTime
Time + TimeSerial(0, 0, 1), "sheet1.倒计时", , TrueElse
[a1] = "00:00:00"
End If
End Sub
在A1单元格输入倒计时开始的小时数,如3个小时“3:00”格式自定;
点击“开发工具”-“插入”-“表单控价”,插入一个按钮,打上想要的文字;