ich habe ein, für mich einfach unlösbares, Problem...
In meiner Userform1 habe ich 19 Textboxen und 3 ComboBoxen.
Die Reihenfolge:
Textbox1 - TextBox11 / ComboBox1 / TextBox12 - TextBox14 / ComboBox2 / TextBox15 / ComboBox3 / TextBox16 - TextBox19.
Das Problem:
Der Inhalt der TextBoxen und ComboBoxen sollen in der aufgeführten Reihenfolge in die Tabelle3 in eine Zeile (ab B2) geschrieben werden.
Leider klappt das nur mit den TextBoxen (werden in der Reihenfolge in die Tabelle geschrieben).
Wie kann ich den Inhalt der ComboBoxen in die Tabelle übernehmen?
Schaut euch doch bitte einmal folgenden Code an und fangt an zu stricken...
Private Sub CommandButton1_Click()
Dim intIndex As Integer, bolausgefüllt As Boolean, lngleereZeile As Long
For intIndex = 1 To 11
If Controls("TextBox" & CStr(intIndex)) = "" Then
MsgBox "Da fehlt noch was... ", 48, "Hinweis :-)"
Controls("TextBox" & CStr(intIndex)).SetFocus
Exit Sub
End If
Next
For intIndex = 1 To 1
If Controls("ComboBox" & CStr(intIndex)) = True Then bolausgefüllt = True: Exit For
Next
If Not bolausgefüllt Then
MsgBox "Angabe fehlt... ", 48, "Hinweis :-)"
Exit Sub
End If
For intIndex = 12 To 14
If Controls("TextBox" & CStr(intIndex)) = "" Then
MsgBox "Da fehlt noch was... ", 48, "Hinweis :-)"
Controls("TextBox" & CStr(intIndex)).SetFocus
Exit Sub
End If
Next
For intIndex = 1 To 1
If Controls("ComboBox" & CStr(intIndex)) = True Then bolausgefüllt = True: Exit For
Next
If Not bolausgefüllt Then
MsgBox "Angabe fehlt... ", 48, "Hinweis :-)"
Exit Sub
End If
For intIndex = 15 To 15
If Controls("TextBox" & CStr(intIndex)) = "" Then
MsgBox "Da fehlt noch was... ", 48, "Hinweis :-)"
Controls("TextBox" & CStr(intIndex)).SetFocus
Exit Sub
End If
Next
For intIndex = 1 To 1
If Controls("ComboBox" & CStr(intIndex)) = True Then bolausgefüllt = True: Exit For
Next
If Not bolausgefüllt Then
MsgBox "Angabe fehlt... ", 48, "Hinweis :-)"
Exit Sub
End If
For intIndex = 16 To 19
If Controls("TextBox" & CStr(intIndex)) = "" Then
MsgBox "Da fehlt noch was... ", 48, "Hinweis :-)"
Controls("TextBox" & CStr(intIndex)).SetFocus
Exit Sub
End If
Next
With Worksheets("Tabelle3")
lngleereZeile = .Cells(65536, 2).End(xlUp).Row + 1
If lngleereZeile < 2 Then lngleereZeile = 2
For intIndex = 1 To 19
.Cells(lngleereZeile, intIndex + 1) = Controls("TextBox" & CStr(intIndex))
Controls("TextBox" & CStr(intIndex)) = ""
Next
End With
TextBox1.SetFocus
If lngleereZeile = 107 Then
MsgBox "Tabelle voll... ", 48, "Hinweis :-)"
Unload Me
End If
End Sub
Vielen Dank im Voraus!!!
Grüsse,
Ina