Hi,
I am getting this error:
For:
Module Code:
Workbook:
Top of code:
Bottom of code:
I only want the workbook to close when there has been no SheetChanges in the last 30 minutes. I want the timer to restart every time there is a SheetChange. Right now it is closing at 30minutes from opening.
Can anyone see what the problem is?
Thanks in advance!
I am getting this error:
For:
Module Code:
VBA Code:
Option Explicit
Public Close_Time As Date
Sub start_Countdown()
Close_Time = Now() + TimeValue("00:30:00")
Application.OnTime Close_Time, "close_WB"
End Sub
Sub stop_Countdown()
Application.OnTime Close_Time, "close_WB", , False
End Sub
Sub close_wb()
ThisWorkbook.Save
If Application.Wait(Now + TimeValue("00:00:05")) = True Then
MsgBox "Timed out after 30 minutes - Your work has been saved."
End If
ThisWorkbook.Close
End Sub
Workbook:
Top of code:
VBA Code:
Option Explicit
Private Sub Workbook_Open()
start_Countdown
.........
VBA Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
stop_Countdown
start_Countdown
End Sub
I only want the workbook to close when there has been no SheetChanges in the last 30 minutes. I want the timer to restart every time there is a SheetChange. Right now it is closing at 30minutes from opening.
Can anyone see what the problem is?
Thanks in advance!