|
方法1
Sub Test()
Const Pause = 3 ' 3 seconds
Dim Start As Single
Dim i As Integer
i = 1
Do While True
Start = Timer
Do While Timer < Start + Pause
DoEvents ' 將程式執行權讓給其它程式。
Loop
ActiveSheet.Cells(i, 1).Value = i
ActiveSheet.Cells(i, 2).Value = Timer
i = i + 1
Loop
End Sub
******************************************************
方法2
Sub 時間() Application.OnTime Now + TimeValue("00:00:1"), "更新"
End Sub
Sub 更新()
With Sheets(1): .Cells(1, 5) = Now ' <-- 指定在第一張工作表顯示
.Cells(1, 5).NumberFormat = "h:mm:ss"
[e2] = [e2] + 1
End With: Call 時間
End Sub |
|