View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Alan Alan is offline
external usenet poster
 
Posts: 492
Default Protect single sheets in the woorkbook

As you say, the security on Excel is very weak and anyone with the knowlege
and the will to do so will crack it without doubt, but provided you don't
have any code experts that are determined to break it, it can be done quite
easily.
I've been using this on a Defect Analysis system where several different
people do the inputting for a few years now without problem.
All it basically does is to hide all the worksheets except one, the header
sheet. This is initially achieved using the Workbook Open event in This
Workbook :-

Private Sub Workbook_Open()
Sheet2.Visible = xlSheetVeryHidden
Sheet3.Visible = xlSheetVeryHidden
End Sub

I use 'VeryHidden' as it doesn't show the sheet at all, not even in the
'Format' 'Sheet' screen, the 'Unhide' option is grayed out so there's no
indication that any hidden sheet exists.

To give users access you can use something like this, you can put it in a
module with a Command Button to run it or just incorporate it into the
Workbook Open event. A box asking for a password will appear:-

Sub HideWorksheets()
Dim Reply
Sheet2.Visible = xlSheetVeryHidden
Sheet3.Visible = xlSheetVeryHidden
Reply = InputBox("Please Enter Your Passsword")
If Reply = "Password1" Then
Sheet2.Visible = True
Else
If Reply = "Password2" Then
Sheet3.Visible = True
Else
If Reply = "Admin" Then
Sheet2.Visible = True
Sheet3.Visible = True
Else: GoTo Error
End If: End If: End If
Exit Sub
Error: MsgBox "Incorrect Password"
End Sub

Remember that only Sheet 1 is visible on opening. If you enter 'Password1',
Sheet 2 becomes visible, 'Password2', Sheet 3 becomes visible, 'Admin' makes
Sheet 2 and Sheet 3 visible. If a non existent password is entered the error
message pops up.

Try pasting the code into a new workbook to try it out.

Don't forget to password protect the VB editor!

Hope this is of use, please post back if anything is unclear,
Regards,
Alan.


"Aron" wrote in message
...
Hi!

I have got more users for my worksheet. I would like each user to be able
to
watch his/her sheet. That means visibility should be secure by a password.
The best would be if I could be "admin":-)

How can I do that???

I know that security in Excel is thin, but in this case a little security
is
better than nothing.

Please give me some advise!


Best Regards