I missed the detail you mentioned you wanted Sheet1 to be read-only by staff. I fixed that code and solved the multi-password prompts.
Replace ALL the old code with this:
Private Sub Workbook_Open()
Dim i_pwd As String
i_pwd = InputBox("Please Enter Password", "Password Required...")
If i_pwd = "" Then
Exit Sub
End If
Select Case LCase(i_pwd)
Case Is = "staff"
Worksheets("Sheet1").Visible = True
Sheets("Sheet1").Select
Case Is = "admin"
UnhideSheets
Sheets("Sheet1").Select
Case Else
MsgBox "Incorrect password; normal entry only.", vbInformation, "Wrong Password!"
End Select
Exit Sub
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
HideSheets
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
X = False
Sheets("Sheet1").Select
If ActiveSheet.ProtectContents Then X = True
If ActiveSheet.ProtectDrawingObjects Then X = True
If ActiveSheet.ProtectScenarios Then X = True
If X = False Then
HideSheets
ThisWorkbook.Save
UnhideSheets
Else
ThisWorkbook.Save
End If
End Sub
Private Sub HideSheets()
Dim sht As Object
Application.ScreenUpdating = False
Sheets(1).Protect Password:="admin", UserInterfaceOnly:=True
ThisWorkbook.Sheets("Sheet1").Visible = xlSheetVisible
For Each sht In ThisWorkbook.Sheets
If sht.Name <> "Sheet1" Then sht.Visible = xlSheetVeryHidden
Next sht
Application.ScreenUpdating = True
End Sub
Private Sub UnhideSheets()
Dim sht As Object
Application.ScreenUpdating = False
For Each sht In ThisWorkbook.Sheets
sht.Visible = xlSheetVisible
Next sht
Sheets(1).Unprotect Password:="admin"
Application.ScreenUpdating = True
End Sub
Bookmarks