Ok, Ive edited the code so it goes to Sheet 2 when the correct password is entered, but I cant find a code to close the form when it gets to the new page, cos otherwise it cant be closed without me clicking cancel... which closes the whole spreadsheet down.
This is the new code:
Dim Var1 As Integer
Private Sub CommandButton1_Click()
If Text2.Text <> "hello" Then
Select Case Var1
Case Is <= 2
If MsgBox("The password is incorrect", 5, "Incorrect Password") = vbCancel Then Unload Me
Var1 = Var1 + 1
Case Else
MsgBox "You have entered the incorrect password 3 times, login denied. The program will now terminate", vbCritical, "Locked Out"
Unload Me
End Select
Else
If MsgBox("Correct password, access granted", vbOK, "Access Granted") = vbOK Then Sheets("Sheet2").Select
End If
End Sub
Private Sub CommandButton2_Click()
Unload Me
MsgBox "Login cancelled by user", vbExclamation, "Invalid Login"
End Sub
Please help me, cos the deadline is only a few weeks away.
Thanks
Brad