Supportnet Computer
Planet of Tech

Supportnet / Forum / Tabellenkalkulation

Button in Userform springt auf "cancel"





Frage

Hallo zusammen, ich bedarf mal wieder Eurer Hilfe. Ich hab' eine Userform erstellt mit folgendem Code: siehe unten Nachdem ich das Passwort engegeben habe springt der Cursor auf den Button "abbrechen" anstatt auf "ok" Muß ich im Code etwas ändern? Danke für Eure Unterstützung, Gruß meikel Private Sub CommandButton1_Click() If TextBox1 = "hallo" Then Unload Me intC = 0 Sheets("sheet1").Visible = True Sheets("sheet1").Activate Else intC = intC + 1 If intC <= 2 Then If MsgBox("Your password is wrong!", vbRetryCancel + vbExclamation, _ "Sorry") = vbCancel Then Unload Me Exit Sub End If TextBox1 = "" TextBox1.SetFocus Else MsgBox "You have entered the wrong password thrice and " & vbLf & _ "your account has been locked!" & vbLf & vbLf & _ "The workbook will be closed!", vbOKOnly + vbExclamation, "Access denied" ActiveWorkbook.Close End If End If End Sub Private Sub CommandButton2_Click() Unload Me End Sub

Antwort 1 von Hajo_Zi

Hallo Meikel,

hast Du mal mit rechter Maustaste die Aktivierungsreihenfolge geprüft?

Gruß Hajo

Antwort 2 von Meikel

Hallo Hajo,

danke vielmals, das wars.

Viele Grüße, meikel