Dim bOK2Use As Boolean
Private Sub btnOK_Click()
Dim bError As Boolean
Dim sSName As String
Dim p As DocumentProperty
Dim bSetIt As Boolean
bOK2Use = False
bError = True
If Len(txtUser.Text) > 0 And Len(txtPass.Text) > 0 Then
bError = False
Select Case txtUser.Text
Case "cxcxax"
sSName = "Blah Blah Blah"
If txtPass.Text <> "EXXXXXX" Then bError = True
Case Else
bError = True
End Select
End If
If bError Then
MsgBox "Invalid User or Employee ID"
Else
'Set document property
bSetIt = False
For Each p In ActiveWorkbook.CustomDocumentProperties
If p.Name = "auth" Then
p.Value = sSName
bSetIt = True
Exit For
End If
Next p
If Not bSetIt Then
ActiveWorkbook.CustomDocumentProperties.Add _
Name:="auth", LinkToContent:=False, _
Type:=msoPropertyTypeString, Value:=sSName
End If
Sheets(sSName).Visible = True <-- IT STOPS RIGHT HERE
Sheets(sSName).Unprotect (txtPass.Text)
Sheets(sSName).Activate
bOK2Use = True
Unload UserForm1
End If
End Sub