Hi all,
been trying to follow this thread "Creating a login page with Excel" in order to protect Workbooks of results from bi-monthly testing of equipment at our treatment plant. I have a workbook, I have created a front sheet with text boxes and a command button. I have veryhidden all but the front sheet. I have changed the username and password controls and I have named all the sheet that need unloading. It will not unload, gets to unload me and stops, I'm not a programmer in any way shape or form, I do try but have very little understanding. Code attached
Private Sub CommandButton1_Click()
Dim username, password As String
username = TextBox1.Text
password = TextBox2.Text
If username = "finbar01" And password = "finbar01" Or username = "finbar02" And password = "finbar02" Or username = "finbar03" And password = "finbar03" Then
MsgBox "You entered the correct info", vbInformation
Unload Me
Sheets("TUS REPORT FRONT SHEET").Visible = True
Sheets("SALT BATH 15 Cyanide").Visible = True
Sheets("SALT BATH 5").Visible = True
Sheets("SALT BATH 10").Visible = True
Sheets("SALT BATH 11").Visible = True
Sheets("SALT BATH 14 SULFINUZ").Visible = True
Sheets("TOP HAT").Visible = True
Sheets("AL 1").Visible = True
Sheets("AL 2").Visible = True
Sheets("AL 3").Visible = True
Sheets("AL 4").Visible = True
Sheets("AL 5").Visible = True
Sheets("NR 1").Visible = True
Sheets("NR 2").Visible = True
Sheets("Large QS").Visible = True
Else
MsgBox "You entered the WRONG info", vbCritical
'now close the workbook
ActiveWorkbook.Close
End If
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "You can't close the dialog like this!"
End If
End Sub
Bookmarks