View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default password protect a sheet

And how will that allow you to see the sheet tab but not the contents as
your original post required?


Gord

On Mon, 27 Oct 2008 13:20:07 -0700, Joe
wrote:

Thanks, I'll try this.

"Mike H" wrote:

Joe,

Alt+F11 to open VB editor, double click 'This Workbook' and paste the code
below in on the right. Change the name of the worksheet to the one you want
to protect.

You should be aware that there is no foolproof way of doing this and that
this method is a deterrent only.


Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ws = ("Sheet2")
If ActiveSheet.Name = (ws) Then
ActiveSheet.Visible = False
response = InputBox("Enter password")
If response = "MyPass" Then
Sheets(ws).Visible = True
Application.EnableEvents = False
Sheets(ws).Activate
Application.EnableEvents = True
Else
MsgBox "Your not allowed to see that sheet"
Sheets(ws).Visible = True
End If
End If
End Sub


Mike


"Joe" wrote:

Is there a way to prevent someone from viewing a worksheet. I know that I
can hide the worksheet and then password protect the workbook to prevent the
user from unhiding the sheet. I would prefer to still see the tabs but not
allow anyone to view that worksheet.