View Single Post
  #6   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

Sub LogOut()
Dim Repsonse
Response = MsgBox("Do you want to update and exit?", vbYesNo, "Caution . .
..")
If Response = vbYes Then
ThisWorkbook.Save
MsgBox "File Saved, Click OK to exit."
ThisWorkbook.Close
End If
End Sub

I'm not sure if sharing the file is a good idea, not sure what would happen
with two users looking at different sheets with the rest hidden and one of
them saved the file,
Regards,
Alan.
"Aron" wrote in message
...
Hey!

The code worked out for me in the end...

I'm happy about that! Now I would just like a "Logout"-button, which
closes
the sheet and the workbook. Saves firts...

Does anyone know if it's a good idea to make the workbook "shared" in case
of two people "updating" their sheets at the same time from different pcs.
(The workbook will be placed on the server)!






"Aron" skrev:

Hey Alan!

Wow, great! It works!

The fact is that I would just like to try that solution for ten
users/sheets. I have tried to extend the code:

Sub HideWorksheets()
Dim Reply
Ark2.Visible = xlSheetVeryHidden
Ark3.Visible = xlSheetVeryHidden
Ark4.Visible = xlSheetVeryHidden
Ark5.Visible = xlSheetVeryHidden
Ark6.Visible = xlSheetVeryHidden
Ark7.Visible = xlSheetVeryHidden
Ark8.Visible = xlSheetVeryHidden
Ark9.Visible = xlSheetVeryHidden
Ark10.Visible = xlSheetVeryHidden
Reply = InputBox("Please Enter Your Passsword")
If Reply = "Password2" Then
Ark2.Visible = True
Else
If Reply = "Password3" Then
Ark3.Visible = True
Else
If Reply = "Password4" Then
Ark4.Visible = True
Else
If Reply = "Password5" Then
Ark5.Visible = True
Else
If Reply = "Password5" Then
Ark6.Visible = True
Else
If Reply = "Password7" Then
Ark7.Visible = True
Else
If Reply = "Password8" Then
Ark8.Visible = True
Else
If Reply = "Password9" Then
Ark9.Visible = True
Else
If Reply = "Password10" Then
Ark10.Visible = True
Else
If Reply = "Admin" Then
Ark2.Visible = True
Ark3.Visible = True
Ark4.Visible = True
Ark5.Visible = True
Ark6.Visible = True
Ark7.Visible = True
Ark8.Visible = True
Ark9.Visible = True
Ark10.Visible = True
Else: GoTo Error
End If: End If: End If: End If: End If: End If: End If: End If: End If:
End
If:
Exit Sub
Error: MsgBox "Incorrect Password"
End Sub

Unfortunately that doesn't work:( Any ideas??

Afterwards I will try to make an Admin sheet where it's possible to get a
comprehensive view of the individual data.

Thanks a lot!

Aron

"Alan" skrev:

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