From: Mark on
I need to create a security feature which requests the users agreement prior
to entering into a worksheet. How do I do that?
From: Mike H on
Mark,

Right click the sheet tab of the sheet you want to protect, View code and
paste the code below in. Change the ProtectedSheet to the correct sheet name
and the outsheet variable to where you want to go if the user doesn't agree.

A couple of points. If macros aren't enabled it won't work and it provides
very little security because Excel security is weak.

Private Sub Worksheet_Activate()
msg = "Do you agree to the terms and conditions. Y/N?"
ttl = "User Agreement"
Set ProtectedSheet = Sheets("Sheet1") 'Change to suit
Set OutSheet = Sheets("Sheet2") 'Change to suit
ProtectedSheet.Visible = False
response = MsgBox(msg, vbYesNo, ttl)
Application.EnableEvents = False
If response = vbYes Then
ProtectedSheet.Visible = True
ProtectedSheet.Activate
Else
OutSheet.Activate
ProtectedSheet.Visible = True
End If
Application.EnableEvents = True
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Mark" wrote:

> I need to create a security feature which requests the users agreement prior
> to entering into a worksheet. How do I do that?