您的位置:首页 > 编程语言 > VB

【Excel VBA】Timer

2019-03-26 09:51 211 查看


Timer()函数返回自凌晨00:00起的秒数和毫秒数。

Private Sub Constant_demo_Click()
msgbox("Time is : " & Now())
msgbox("Timer is: " & Timer())
End Sub


例子

Sub Counter_Looping_for_Timer()
'for tab Find (for Timer testing)

Dim r As Long
Dim i As Byte
i = 3
Dim Start

' 记录开始的时间
Start = VBA.Timer
Range("D3:D6").ClearContents
'this part is hardcoded for the purpose of testing the Timer Function
For r = 8 To 200000
If UCase(Range("A" & r).Value) = UCase(Range("B3").Value) Then
Range("D" & i).Value = Range("E" & r).Value
i = i + 1
End If
Next r

' 用debug输出运算时间
Debug.Print Round(Timer - Start, 3)

End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: