Hello. So I have a workbook that tracks break times. It does this by counting down from 20 minutes in column E when a value is entered in column A. It is updated every single second. However, when a workbook that is in Protected View and needs to have "Enable editing" selected opens then I get run time error 91, "Object variable or with block variable not set" under the line
ActiveSheet.Range("E3").Calculate
After this the timer will not work on this workbook unless both files are closed and the protected view is removed. How could I edit these codes to remove the protected view and keep calculating the active sheet. Or just identify the sheet that needs the second by second calculation which is titled "Track Break Times.?"
Here are my module codes and then my private subs saved in the workbook
ActiveSheet.Range("E3").Calculate
After this the timer will not work on this workbook unless both files are closed and the protected view is removed. How could I edit these codes to remove the protected view and keep calculating the active sheet. Or just identify the sheet that needs the second by second calculation which is titled "Track Break Times.?"
Here are my module codes and then my private subs saved in the workbook
VBA Code:
Sub UpdateTime()
ActiveSheet.Range("E3").Calculate
Call Timer
End Sub
Sub Timer()
Application.OnTime Now + TimeValue("00:00:01"), "UpdateTime"
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime Now + TimeValue("00:00:01"), "UpdateTime", Schedule:=False
End Sub
Private Sub Workbook_Open()
UpdateTime
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call StopTimer
End Sub