Ik heb een code gemaakt en zou graag hebben als het passwoord fout is dat dan de private sub afsluit zodat je niet verder kan gaan naar de volgende msgbox. Hoe moet ik dat dan aanpassen?
Code:
Private Sub CommandButton2_Click()
Dim mypassword
tryagain:
mypassword = InputBox("Enter Password", "Password")
If mypassword = "yourpassword" Then
'your code here
MsgBox ("Correct")
Else
If MsgBox("Password incorrect, try again?", vbYesNo, "Wrong password") = vbYes Then GoTo tryagain
End If
If MsgBox("Are you sure that you wish to clear the contents?", vbYesNo, "Confirm") = vbYes Then
Range("A3").Select
Selection.SpecialCells(xlCellTypeConstants, 1).Select
Selection.ClearContents
End If
End Sub