Auto Macro

BENSONJR

New Member
Joined
Sep 13, 2009
Messages
10
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
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
If the user does not put an x in IntroSheet (for example - n ot in the code I sent you yet) A1 within 4 seconds, Blanksheet is activated. Also, the intruder should not be able to touch the workbook at all. This is a form of protection if you will. Thank you for your interest and help . . .
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top