VBA 如何计算一段代码运行需要的时间?
更精准
Private Sub Form_Load()
Dim sngStart As Single
sngStart = Timer
'循环代码
Debug.Print "耗费时间: " & Timer - sngStart
更精准
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Form_Load()
Dim dt As Longdt = GetTickCount
'循环代码
Debug.Print "用时:" & GetTickCountd - dtEnd Sub