thanks celia..u r excellent..regards
Re: why won't this work for me?
I saw this an realized i might be able to use it also.
I tried copying the code into a macro and I couldn't
get it to work. I am new to macros but am trying to
learn quickly.
I was able to copy other code in and it worked.
Help please.
Thanks
Re: why won't this work for me?
George
You have to put it in the Workbook module, not in a normal module.
Celia
the sheets names r 1,2,3.. i don't want user to look in sheet2...
Newby
Try the following. The password is "Only4Me". Change it to whatever you want.
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim passWord As Variant
If ActiveSheet.Name = "Sheet2" Then
Application.EnableEvents = False
Sheets("Sheet1").Activate
passWord = Application.InputBox _
(Prompt:="Input password to activate Sheet2")
Else
Application.EnableEvents = True
Exit Sub
End If
Do
If passWord = "False" Then
Application.EnableEvents = True
Exit Sub
ElseIf passWord = "Only4Me" Then
Application.EnableEvents = False
Sheets("Sheet2").Activate
Application.EnableEvents = True
Exit Sub
Else
MsgBox "Invalid password"
passWord = Application.InputBox _
(Prompt:="Input password to activate Sheet2")
End If
Loop
End Sub
Celia