Hide/Unhide worksheets based on login?

  • Thread starter Thread starter jej1216
  • Start date Start date
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
 
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
 
Back
Top