ich habe eine UserForm mit zwei Textfeldern zur Passwordabfrage.
Nun möchte ich gerne, das der Commandbutton1 erst dann aktiv wird, wenn beide Textfelder ausgefüllt sind.
Den Code habe ich ich hier aus dem Forum erhalten.
Wer kann mir den Codeschnipsel entsprechend anpassen?
LG Ina
Private Sub UserForm_Activate()
CommandButton1.Enabled = False
TextBox1.SetFocus
End Sub
Private Sub CommandButton1_Click()
Dim Na As String, NaFix
Dim Pw As String, PwFix
Static iCounter As Integer
NaFix = Array("Testfrau")
PwFix = Array("12345")
Na = TextBox1
Pw = TextBox2
iCounter = iCounter + 1
If IsError(Application.Match(Na, NaFix, 0)) Then
MsgBox "Name falsch"
If iCounter = 3 Then ActiveWorkbook.Close False
TextBox1 = ""
TextBox2 = ""
TextBox1.SetFocus
Exit Sub
End If
If Pw PwFix(Application.Match(Na, NaFix, 0) - 1) Then
MsgBox "Passwort falsch"
If iCounter = 3 Then ActiveWorkbook.Close False
TextBox2 = ""
TextBox2.SetFocus
Exit Sub
End If
'If TextBox1 > "" And TextBox2 > "" Then CommandButton1.Enabled = True 'Klappt nicht!
MsgBox "Sie dürfen rein!"
Unload Me
End Sub