Originally Posted by
mdmackillop
I recall some KB items for enforcing macros, but for your own code, try this
[vba]
'Standard module
Sub GoToBlankSheet()
If Not UCase(Sheets("Customs").Range("A1")) = "X" Then
ThisWorkbook.Sheets("Immigration").Activate
End If
End Sub
'Workbook Module
Option Explicit
Dim RunTime
Private Sub Workbook_Open()
Sheets("Customs").Range("A1").ClearContents
Sheets("Customs").Activate
SetTime
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Dim keyCell As Range, testFor As String
Set keyCell = Sheets("Customs").Range("A1"): Rem adjust
testFor = "x": Rem adjust
Select Case Sh.Name
Case Is = "Immigration"
Rem Do Nothing
Case Else
If UCase(keyCell.Text) = UCase(testFor) Then
Call StopTime
End If
End Select
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
If Sh.Name = "Immigration" Then
Call SetTime
Else
Call StopTime
End If
End Sub
Sub SetTime()
RunTime = Now + TimeValue("00:00:04"): Rem adjust delay
Application.OnTime RunTime, "GoToBlankSheet"
End Sub
Sub StopTime()
On Error Resume Next
Application.OnTime RunTime, "GoToBlankSheet", schedule:=False
On Error GoTo 0
End Sub
[/vba]