wie kann ich folgenden Code anpassen, dass dieser bei leerer Textbox1 eine MsgBox enthält:
Private Sub CommandButton2_Click()
'Prüft, ob in Textfeld 5 ein Datum
If IsDate(TextBox5) = False Then
MsgBox "Fehler: Datumsformat fehlerhaft."
Exit Sub
End If
'Prüft, ob in Textfeld 6 ein Datum
If IsDate(TextBox5) = False Then
MsgBox "Fehler: Datumsformat fehlerhaft."
Exit Sub
End If
Dim xZeile As Long
If TextBox1 = "" Then Exit Sub
If ComboBox1.ListIndex = 0 Then
xZeile = [A65536].End(xlUp).Row + 1
Else
xZeile = ComboBox1.ListIndex + 1
End If
Cells(xZeile, 1) = TextBox1
Cells(xZeile, 2) = TextBox2
Cells(xZeile, 3) = TextBox3
Cells(xZeile, 4) = ComboBox2
Cells(xZeile, 5) = TextBox5
Cells(xZeile, 6) = TextBox6
Columns("A:F").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
UserForm_Initialize
End Sub
Gruss
bernd