ich hoffe ihr könnt mir helfen. Ich habe eine Tabelle, die durch TextBoxen gefüllt wird. Nun ist es so, dass auf einem anderen Userform mittels einem TextBox (Suchkriterium) die passende Zeile/n in einer ListBox1 angezeigt werden. Durch klicken, werden die Textboxen gefüllt und in einer TextBox (ungefüllt) das Datum ergänzt wird und durch ein CommandButton die Zeile geändert und zurückgeben wird. Das klappt alles soweit.
Mein Problem ist, dass ich:
1. Nur eine Markierung im ListBox anklicken kann. Klicke eine andere Markierung an,
bringt er mir eine Fehlermeldung.
2. Zeigt er mir zuviele Ergebnisse an. Ich möchte nur, dass die Zeilen angezeigt
werden, welche dem Suchkriterum (Zahl) entspricht und nur die Zeile angezeigt
wird, in der eine bestimmte Zelle noch nicht befüllt ist.
Hier mal meine Codes:
Private Sub CommandButton3_Click()
Dim Found As Range
Dim FirstAddress As String
Dim Search As String
Dim Zeile As Long
Zeile = 0
Search = TextBox2
If Search = "" Then Exit Sub
Me.ListBox1.ColumnCount = 9
Me.ListBox1.ColumnWidths = "0;170;70;0;263;0;150;0;0"
With Sheets("Tabelle1").Range("A6:A65536")
Set Found = .Find(Search, LookIn:=xlValues, LookAt:=xlWhole)
TextBox2.Tag = ""
TextBox15 = ""
If Not Found Is Nothing Then
FirstAddress = Found.Address
Do
TextBox2.Tag = TextBox2.Tag & ";" & Found.Row
Me.ListBox1.AddItem
Me.ListBox1.List(Zeile, 1) = Found.Offset(0, 1)
Me.ListBox1.List(Zeile, 2) = Found.Offset(0, 2)
Me.ListBox1.List(Zeile, 3) = Found.Offset(0, 3)
Me.ListBox1.List(Zeile, 4) = Found.Offset(0, 4)
Me.ListBox1.List(Zeile, 5) = Found.Offset(0, 5)
Me.ListBox1.List(Zeile, 6) = Found.Offset(0, 6)
Me.ListBox1.List(Zeile, 7) = Found.Offset(0, 7)
Me.ListBox1.List(Zeile, 8) = Found.Offset(0, 8)
Me.ListBox1.List(Zeile, 9) = Found.Offset(0, 9)
Set Found = .FindNext(Found)
Zeile = Zeile + 1 '
Loop While Not Found Is Nothing And Found.Address FirstAddress
If Zeile = 1 Then
End If
Else
TextBox15.Text = "Keine fortlaufende Nummer gefunden"
ListBox1.Clear
End If
End With
TextBox2.Tag = Mid(TextBox2.Tag, 2)
Private Sub ListBox1_Click()
Dim selected As Integer
selected = Me.ListBox1.ListIndex
Me.TextBox1 = Me.ListBox1.List(selected, 1)
Me.TextBox3 = Me.ListBox1.List(selected, 2)
Me.TextBox4 = Me.ListBox1.List(selected, 4)
Me.TextBox5 = Me.ListBox1.List(selected, 6)
Me.TextBox6 = Me.ListBox1.List(selected, 7)
Me.TextBox7 = Me.ListBox1.List(selected, 8)
TextBox2.Tag = Split(TextBox2.Tag, ";")(selected)
End Sub
--------------------------------------------------------------------
Sheets("Tabelle1").Visible = True
Sheets("Tabelle1").Select
ActiveSheet.Unprotect
Dim manipulierte_Zeile As Integer
If TextBox2.Tag = "" Then Exit Sub
manipulierte_Zeile = CLng(TextBox2.Tag)
Sheets("Tabelle1").Cells(manipulierte_Zeile, 2) = Format(TextBox1, "DD.MM.YYYY")
Sheets("Tabelle1").Cells(manipulierte_Zeile, 3) = Format(TextBox3.Text)
Sheets("Tabelle1").Cells(manipulierte_Zeile, 5) = Format(TextBox4.Text)
Sheets("Tabelle1").Cells(manipulierte_Zeile, 7) = Format(TextBox5.Text)
Sheets("Tabelle1").Cells(manipulierte_Zeile, 8) = Format(TextBox6.Text)
Sheets("Tabelle1").Cells(manipulierte_Zeile, 9) = Format(TextBox7, "DD.MM.YYYY")
ActiveSheet.Protect
Sheets("Tabelle1").Visible = False
TextBox2.Tag = ""
Unload Me
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
With Me.ListBox1
If .ListIndex > -1 Then .RemoveItem (.ListIndex)
End With
UserForm7.Show
UserForm3.Hide