I was given the code below but I cannot make it work. Even I placed an x in the A1 cell of blankSheet, I can go to another sheet and make a minor change before blanksheet is again activated. I am using this as a form of protection for intruders. What am I missing? Could someone help me with this please? Thank you very much . . .
Normal module
Sub GoToBlankSheet()
ThisWorkbook.Sheets("blankSheet").Activate
End Sub
and this in ThisWorkbook
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Dim keyCell As Range, testFor As String
Set keyCell = Sh.Range("A1"): Rem adjust
testFor = "x": Rem adjust
Select Case Sh.Name
Case Is = "blankSheet"
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)
Call stopTime
If Sh.Name = "blankSheet" Then
Call setTime
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
Normal module
Sub GoToBlankSheet()
ThisWorkbook.Sheets("blankSheet").Activate
End Sub
and this in ThisWorkbook
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Dim keyCell As Range, testFor As String
Set keyCell = Sh.Range("A1"): Rem adjust
testFor = "x": Rem adjust
Select Case Sh.Name
Case Is = "blankSheet"
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)
Call stopTime
If Sh.Name = "blankSheet" Then
Call setTime
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