我目前正在使用以下代码来确定某个宏运行所需的时间。
Sub Timer ()
Dim StartTime As Double
Dim SecondsElapsed As Double
StartTime = Timer
'Some macro executed
SecondsElapsed = Round(Timer - StartTime, 2)
MsgBox "This code ran successfully in " & SecondsElapsed & " seconds", vbInformation
End Sub
现在,我想将此计时器用于使用按钮连续执行的几个宏。我正在寻找类似的东西:
<Button>
'Dim StartTime As Double
'Dim SecondsElapsed As Double
StartTime = Timer
Macro1
Macro2
Macro3
SecondsElapsed = Round(Timer - StartTime, 2)
MsgBox "This code ran successfully in " & SecondsElapsed & " seconds", vbInformation
<Button>
答案 0 :(得分:2)
您可以只在主计时器代码中调用宏
val.someProperty
如果您想知道每个人花了多长时间,只需为每个宏声明一个SecondsElapsed变量,并在每个Call语句后填充它即可。