Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Name <> "Summary" Then ws.Visible = xlSheetVeryHidden
Next ws
ThisWorkbook.Save
End Sub
Private Sub Workbook_Open()
Dim user As String, pwd As String, Correctpwd As String, ShtName As String
Dim ct As Long, LR As Long
Dim C As Range
Dim ws As Worksheet
Dim Manager As Boolean
LR = Sheets("LogIn").Cells(Rows.Count, "A").End(xlUp).Row
user = InputBox("Enter your UserName")
Set C = Worksheets("LogIn").Range("$A1:$A" & LR).Find(What:=user, LookIn:=xlValues, MatchCase:=False, SearchFormat:=False)
If Not C Is Nothing Then
Manager = (C.Offset(, 2) = "Y")
If Manager Then
Correctpwd = C.Offset(, 3)
Do While ct < 3 And pwd <> Correctpwd
pwd = InputBox("Enter Password: " & 3 - ct & " tries left")
ct = ct + 1
Loop
If pwd = Correctpwd Then
For Each ws In Worksheets
If ws.Name <> "LogIn" Then
ws.Visible = True
End If
Next ws
Else
MsgBox "Incorrect manager password, access to Summary only"
End If
Else
Sheets(C.Offset(, 1).Value).Visible = True
End If
Else
MsgBox "Not a valid user, access to Summary only"
End If
End Sub