Hallo Allerseits.
Nachdem ich mir jetzt mehrere Tage den Kopf darüber zerbrochen habe bin ich mit meinem Laien-Latein am Ende.
Ich versuche aktuell ein Makro zu schreiben, das eine Art Aufgabenliste erstellt. Mittels Internet-Tutorial konnte ich jetzt eine Eingabemaske erstellen, und diese von Zeile 2 abwärts Einträge generieren lassen.
Nun hatte ich vor mir solange ein Eintrag in der Liste markiert ist, eine andere Liste die mittels Textfeld und CommandBox speisbar ist, anzeigen zu lassen.
Sprich Wenn Markierter Text in ListBox1 identisch mit Tabelle1 Zeile1 ist, soll TextBox7 nach Click von CommandBox5 ein neues Item in die ListBox2 setzen und speichern. ListBox2 soll gecleart werden sobald in ListBox1 ein anderer Text markiert ist.
Außerdem hatte ich vor in die letzte Zeile ein DropDown mit 3 farbigen Stati und den Optionen "Dringend" "In Arbeit" und "Erledigt" erstellen zu lassen, aber ich vermute selbst da wäre ich überfordert.
Kann jemand von euch Profis einem Praktikanten mit Druck von oben aushelfen?
Der Code für die Maske ist von vba-online.de aus deren Tutorial das ich zum lernen genutzt habe
https://imgur.com/a/HewiaBi
Private Sub CommandButton1_Click()
Dim lZeile As Long
lZeile = 2
Do While Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) <> ""
lZeile = lZeile + 1
Loop
Tabelle1.Cells(lZeile, 1) = CStr("Neuer Eintrag Zeile " & lZeile)
ListBox1.AddItem CStr("Neuer Eintrag Zeile " & lZeile)
ListBox1.ListIndex = ListBox1.ListCount - 1
End Sub
Private Sub CommandButton2_Click()
Dim lZeile As Long
If ListBox1.ListIndex = -1 Then Exit Sub
lZeile = 2
Do While Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) <> ""
If ListBox1.Text = Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) Then
Tabelle1.Rows(CStr(lZeile & ":" & lZeile)).Delete
Call UserForm_Initialize
If ListBox1.ListCount > 0 Then ListBox1.ListIndex = 0
Exit Do
End If
lZeile = lZeile + 1
Loop
End Sub
Private Sub CommandButton3_Click()
Dim lZeile As Long
If ListBox1.ListIndex = -1 Then Exit Sub
If Trim(CStr(TextBox1.Text)) = "" Then
MsgBox "Sie müssen mindestens einen Namen eingeben!", vbCritical + vbOKOnly, "Fehler"
Exit Sub
End If
lZeile = 2
Do While Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) <> ""
If ListBox1.Text = Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) Then
Tabelle1.Cells(lZeile, 1).Value = Trim(CStr(TextBox1.Text))
Tabelle1.Cells(lZeile, 2).Value = TextBox2.Text
Tabelle1.Cells(lZeile, 3).Value = TextBox3.Text
Tabelle1.Cells(lZeile, 4).Value = TextBox4.Text
Tabelle1.Cells(lZeile, 5).Value = TextBox5.Text
Tabelle1.Cells(lZeile, 6).Value = TextBox6.Text
If ListBox1.Text <> Trim(CStr(TextBox1.Text)) Then
Call UserForm_Initialize
If ListBox1.ListCount > 0 Then ListBox1.ListIndex = 0
End If
Exit Do
End If
lZeile = lZeile + 1
Loop
End Sub
Private Sub CommandButton4_Click()
Unload Me
End Sub
Private Sub ListBox1_Click()
Dim lZeile As Long
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
If ListBox1.ListIndex >= 0 Then
lZeile = 2
Do While Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) <> ""
If ListBox1.Text = Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) Then
TextBox1 = Trim(CStr(Tabelle1.Cells(lZeile, 1).Value))
TextBox2 = Tabelle1.Cells(lZeile, 2).Value
TextBox3 = Tabelle1.Cells(lZeile, 3).Value
TextBox4 = Tabelle1.Cells(lZeile, 4).Value
TextBox5 = Tabelle1.Cells(lZeile, 5).Value
TextBox6 = Tabelle1.Cells(lZeile, 6).Value
Exit Do
End If
lZeile = lZeile + 1
Loop
End If
End Sub
Private Sub TextBox7_Change()
ListBox2.AddItem TextBox7.Text
If ListBox1.Text <> Trim(CStr(TextBox1.Text)) Then
Call UserForm_Initialize
If ListBox2.ListCount > 0 Then ListBox2 = 0
End If
End Sub
Private Sub UserForm_Activate()
If ListBox1.ListCount > 0 Then ListBox1.ListIndex = 0
End Sub
Private Sub UserForm_Initialize()
Dim lZeile As Long
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
ListBox1.Clear
lZeile = 2
Do While Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) <> ""
ListBox1.AddItem Trim(CStr(Tabelle1.Cells(lZeile, 1).Value))
lZeile = lZeile + 1
Loop
End Sub
'Das hier ist der Problemteil
Private Sub Teilaufgaben()
Dim lZeile As Long
TextBox7 = " "
If ListBox1.ListIndex >= 0 Then
lZeile = 2
Do While Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) <> " "
If ListBox1.Text = Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) Then
TextBox7 = ListBox2
lZeile = lZeile + 1
ListBox2.AddItem (CStr("Neue Aufgabe" & lZeile))
End If
End Sub
Private Sub TeilAufgabenBox()
If ListBox2.ListIndex = -1 Then Exit Sub
lZeile = 2
Do While Trim(CStr(Tabelle1.Cells(Zeile1, 1).Value)) <> " "
If ListBox1.Text = Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) Then
Tabelle2.Cells(lZeile, 1).Value = Trim(CStr(TextBox1.Text))
Tabelle2.Cells(lZeile, 2).Value = TextBox7.Text
TextBox7 = ""
Tabelle2.Cells(lZeile, 1).Value = TextBox7.Text
If ListBox1.Text <> Trim(CStr(TextBox1.Text)) Then
Call UserForm_Initialize
If ListBox1.ListCount > 0 Then ListBox1.ListIndex = 0 & ListBox2.ListIndex = 0
End If
End If
Loop
End Sub
|