【发布时间】:2018-02-21 09:29:48
【问题描述】:
我按照https://www.thespreadsheetguru.com/the-code-vault/2015/1/28/vba-calculate-macro-run-time 在 VBA 中运行了一些代码,结果返回了一个负值:
-20439 秒
有人知道为什么吗?它实际上运行了〜18小时(第二天1500-0900)
Option Explicit
Sub CalculateRunTime_Minutes()
'PURPOSE: Determine how many minutes it took for code to completely run
'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault
Dim StartTime As Double
Dim MinutesElapsed As String
'Remember time when macro starts
StartTime = Timer
'*****************************
'Insert Your Code Here...
'*****************************
'Determine how many seconds code took to run
MinutesElapsed = Format((Timer - StartTime) / 86400, "hh:mm:ss")
'Notify user in seconds
MsgBox "This code ran successfully in " & MinutesElapsed & " minutes", vbInformation
End Sub
【问题讨论】:
-
如果你的代码需要 18 小时才能运行——也许它需要Code Review
标签: vba excel timer negative-number