ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I password-protect a spreadsheet for different users? (https://www.excelbanter.com/excel-programming/343821-can-i-password-protect-spreadsheet-different-users.html)

Candy

Can I password-protect a spreadsheet for different users?
 
In short, here is the situation:
An Excel spreadsheet is created with the work scheduals of 20 employees. It
can be sorted (example: "Amy" or "Bob"). The problem is, Amy can see Bob's
schedual and vice versa. Is there a way to prevent employees from seeing any
but their own schedual?

Jim Thomlinson[_4_]

Can I password-protect a spreadsheet for different users?
 
You could do something similar to this. Have a main sheet that is always
visible. You will want some code in the on on open event to hide all but the
main sheet and the same code in the on close. This will cover off macros
enabled or disabled causing a problem and keep prying eyes generall out of
stuff that they are not supposed to see.

The on open and on close should call this

Sub HideAll()
dim wks as worksheet

for each wks in worksheets
if wks.name < "Main" Then wks.visible = xlVeryHidden
next wks
End sub

In the on open you also want to have code similar to this after the
HideAll()...

on error goto errorhandler
sheet(environ("UserName")).visible = xlVisible

exit Sub
Errorhandler:
msgbox "There is no sheet with your name"
end sub

The only thing left to do is to rename all of the sheets with the individual
employees user names. This is the name that they use to log into windows.

If you need more assistance or if this all sounds to difficult reply back
and we can give you futher help.
--
HTH...

Jim Thomlinson


"Candy" wrote:

In short, here is the situation:
An Excel spreadsheet is created with the work scheduals of 20 employees. It
can be sorted (example: "Amy" or "Bob"). The problem is, Amy can see Bob's
schedual and vice versa. Is there a way to prevent employees from seeing any
but their own schedual?



All times are GMT +1. The time now is 10:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com