Skip to content

Instantly share code, notes, and snippets.

@ateneva
Last active July 21, 2018 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ateneva/94df273d3b9beeba39a3b11047ff4d23 to your computer and use it in GitHub Desktop.
Save ateneva/94df273d3b9beeba39a3b11047ff4d23 to your computer and use it in GitHub Desktop.
Only hide worksheets if the user is authorises to view them
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