Hide/Unhide worksheets based on login?

J

jej1216

Is it possible to have an Excel spreadsheet that hides/unhides
worksheets based on the Active Directory network login? If that is not
possible, how about a login into the Workbook and then do hide/unhide
based on that?

Advice on how to do either?

Thanks in Advance.

Joe
 
G

Guest

Environ("UserName")

should get you the login name. My suggestion would be to use the very hidden
attribute of the visible property. Additionally when the file is being closed
make sure that you set the hidden property for all of the confidential sheets
to very hidden. Otherwise if the book is opened with macros disabled the
confidential sheets may still be visible. Ensure that the code to hide and
unhide the sheets is not accessible through the Macro's menu - "Option
Private Module" - at the top of the code will ensure that the macro's are
not visible to the user. Make shure that your code is protected with a
password. Finally after all of this there is nothing to stop the user from
writing a simple script such as this to unhide the sheets anyways...

sub UnhideAll
dim wks as worksheet
for each wks in activeworkbook.worksheets
wks.visible = xlSheetVisible
next wks

exit sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top