Hi all,
I have this Timeout_Module:
It seems to work fine but after 30 minutes it closes my spreadsheet regardless of:
Call StopTimer
Call StartTimer
Restarting the timer the below code:
Even though I am entering text or clicking around the spreadsheet will still close after 30 minutes intermittently.
I can't seem to put a finger on why it is doing this.
Any help would be greatly appreciated!
Thank you in advance
I have this Timeout_Module:
VBA Code:
Option Explicit
Public DownTime As Double
Sub StartTimer()
DownTime = Now + TimeSerial(0, 30, 0)
Application.OnTime DownTime, "ShutDown"
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime DownTime, "ShutDown", , False
End Sub
Sub ShutDown()
With ThisWorkbook
Application.DisplayAlerts = False
.Close Savechanges:=True
Application.DisplayAlerts = True
End With
End Sub
It seems to work fine but after 30 minutes it closes my spreadsheet regardless of:
Call StopTimer
Call StartTimer
Restarting the timer the below code:
VBA Code:
Option Explicit
' Ignore Errors when Worksheet Activated
Private Sub Worksheet_Activate()
Call StartTimer 'Start Timeout timer
Dim r As Range: Set r = Range("A2:AQ200")
Dim cel As Range
For Each cel In r
With cel
.Errors(8).Ignore = True 'Data Validation Error
.Errors(9).Ignore = True 'Inconsistent Error
.Errors(6).Ignore = True 'Lock Error
End With
Next cel
End Sub
Private Sub Worksheet_Deactivate()
Call StopTimer 'Stop Timeout timer so it can stay open when on other sheets
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.CutCopyMode = False Then
Application.Calculate ' Refresh for Grey Line
End If
Call StopTimer 'Stop Timeout timer
Call StartTimer 'Restart Timeout timer
End Sub
Private Sub Worksheet_Calculate()
' Ignore Errors after Sorting
Dim r As Range: Set r = Range("A2:AQ200")
Dim cel As Range
For Each cel In r
With cel
.Errors(8).Ignore = True 'Data Validation Error
.Errors(9).Ignore = True 'Inconsistent Error
.Errors(6).Ignore = True 'Lock Error
End With
Next cel
Call StopTimer 'Stop Timeout timer
Call StartTimer 'Restart Timeout timer
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Const sURI As String = "https://cases.com/ui/cases/"
If Target.Count <> 1 Then Exit Sub
If Not Intersect(Target, Range("Q3:Q200")) Is Nothing Then
On Error GoTo ErrLine
Application.EnableEvents = False
With ActiveWorkbook.Styles("Followed Hyperlink").Font
.Color = RGB(0, 0, 0)
End With
If Target.Value <> "" Then
ActiveSheet.Hyperlinks.Add Anchor:=Cells(Target.Row, "A"), Address:= _
sURI & Target.Value, TextToDisplay:=Cells(Target.Row, "A").Value
Else
Cells(Target.Row, "A").Hyperlinks.Delete
End If
With Cells(Target.Row, "A").Font
.Parent.Style = "Normal"
.Name = "Calibri"
.Size = 12
.Bold = True
.Color = vbBlack
.Underline = xlUnderlineStyleNone
End With
End If
If Target.CountLarge / Rows.Count = Int(Target.CountLarge / Rows.Count) Then Exit Sub 'Exit code if whole columns are edited
' Copy from Line 200 into deleted cells
Dim Changed As Range, c As Range
Set Changed = Intersect(Target, Columns("A:AQ"))
If Not Changed Is Nothing Then
Application.EnableEvents = False
For Each c In Changed
If Len(c.Text) = 0 Then Cells(200, c.Column).Copy Destination:=c
Next c
Application.EnableEvents = True
End If
'Ignore Errors with Worksheet Clicks
Dim r As Range: Set r = Range("A2:AQ200")
Dim cel As Range
For Each cel In r
With cel
.Errors(8).Ignore = True 'Data Validation Error
.Errors(9).Ignore = True 'Inconsistent Error
.Errors(6).Ignore = True 'Lock Error
End With
Next cel
ErrLine: 'Just in case, enable event
Application.EnableEvents = True
End Sub
Even though I am entering text or clicking around the spreadsheet will still close after 30 minutes intermittently.
I can't seem to put a finger on why it is doing this.
Any help would be greatly appreciated!
Thank you in advance