Last active
July 21, 2018 23:47
-
-
Save ateneva/94df273d3b9beeba39a3b11047ff4d23 to your computer and use it in GitHub Desktop.
Only hide worksheets if the user is authorises to view them
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub AuthUser() | |
Dim Cell As Range | |
Dim person As String | |
Dim authperson As String | |
person = Application.UserName | |
'---------------------------------------- | |
'written by Angelina Teneva, 2013 | |
'----------------------------------------- | |
For Each Cell In ActiveWorkbook.Worksheets("Names").Range("E1:E100") | |
authperson = Cell.Value | |
If person = authperson Then | |
Worksheets("data").Visible = xlSheetVisible | |
Else | |
Worksheets("data").Visible = xlSheetVeryHidden | |
MsgBox ("Sorry, you are not authorized to view this data") | |
End If | |
Exit For | |
Next Cell | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment