nniedzielski
Well-known Member
- Joined
- Jan 8, 2016
- Messages
- 589
- Office Version
-
- 2019
- Platform
-
- Windows
Hello-
I am running a macro that does an audit of a spreadsheet, im adding in functionality and timer code, but i cannot get the time to work, this is what i have so far, and right now the timer always says it ran in zero seconds, even if i step through the code to ensure it was longer than 0 seconds.
I am running a macro that does an audit of a spreadsheet, im adding in functionality and timer code, but i cannot get the time to work, this is what i have so far, and right now the timer always says it ran in zero seconds, even if i step through the code to ensure it was longer than 0 seconds.
VBA Code:
Option Explicit
Option Compare Text
Public Sub bulkPlanAudit()
startTimer
turnOffFunctionality
auditSteps
stopTimer
turnOnfunctionality
reportTime
End Sub
Public Sub turnOffFunctionality()
Application.Calculation = xlCalculationManual
Application.DisplayStatusBar = False
Application.EnableEvents = False
Application.ScreenUpdating = False
End Sub
Public Sub turnOnfunctionality()
Application.Calculation = xlCalculationAutomatic
Application.DisplayStatusBar = True
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Public Sub startTimer()
Dim startTime As Double
startTime = Timer
End Sub
Public Sub stopTimer()
Dim secondsElapsed As Double
Dim startTime As Double
secondsElapsed = Round(Timer - startTime, 2)
End Sub
Public Sub reportTime()
Dim secondsElapsed As Double
MsgBox "Run time was " & secondsElapsed & " seconds", vbInformation
End Sub
Public Sub auditSteps()
'this is where my main code will be
End Sub