ich brauche mal wieder Hilfe von jemand der versteht was da passiert.Ich lasse ListBoxeinträge mit einem Suchbegriff aus einer TextBox sortieren.Danach möchte ich diese sortierten Einträge an eine bestimmte Stelle meiner Tabelle übertragen damit ich Sie ausdrucken kann.Funktioniert auch alles prima wenn ich die ListBox nicht vorher sortieren lasse.Nach einer Sortierung werden die Daten zwar auch wie gewünscht in die Tabelle übertragen, aber dann erscheint jedesmal der Debugger mit der Meldung "Eigenschaft List konnte nicht gesetzt werden", !!!
Ich finde den Fehler nicht, kann mir bitte jemand helfen.
Nachfolgend alle Codes die ich verwende.
So wird die ListBox zunächst befüllt:
Private Sub UserForm_Activate()
With Worksheets("Tabelle1")
LoLetzte = IIf(IsEmpty(.Cells(.Rows.Count, 1)), .Cells(.Rows.Count, 1).End(xlUp).Row, .Rows. _
Count)
ListBox1.RowSource = "A2:K" & LoLetzte
ListBox1.ColumnCount = 11
ListBox1.ColumnWidths = "1,6cm;2,2cm;2,7cm;2,5cm;2,8cm;1,5cm;2,7cm;2,4cm;2,3cm;0,8cm;0,0cm"
End With
Dim i As Long
Dim notEmpty As Boolean
notEmpty = False
With Me.ListBox1
For i = 0 To .ListCount - 1
If .List(i) "" Then
notEmpty = True
Exit For
End If
Next i
End With
If notEmpty = False Then Me.ListBox1.Enabled = False
End Sub
So lasse ich die Einträge sortieren:
Private Sub CommandButton1_Click()
Dim LoI As Long
Dim LoZeile As Long
Dim RaFound As Range
Application.ScreenUpdating = False
If TextBox11 = "" Then
ListBox1.RowSource = "A2:J" & LoLetzte
Else
ListBox1.RowSource = ""
With Worksheets("Tabelle1")
Set RaFound = .Columns(1).Find(TextBox11 & "*", .Range("A1"), , xlWhole, , xlNext)
If Not RaFound Is Nothing Then
For LoI = RaFound.Row To LoLetzte
If UCase(Left(.Cells(LoI, 1), Len(TextBox11))) = UCase(TextBox11) Then
ListBox1.AddItem .Cells(LoI, 1).Text
ListBox1.List(LoZeile, 1) = .Cells(LoI, 2).Text
ListBox1.List(LoZeile, 2) = .Cells(LoI, 3).Text
ListBox1.List(LoZeile, 3) = .Cells(LoI, 4).Text
ListBox1.List(LoZeile, 4) = .Cells(LoI, 5).Text
ListBox1.List(LoZeile, 5) = .Cells(LoI, 6).Text
ListBox1.List(LoZeile, 6) = .Cells(LoI, 7).Text
ListBox1.List(LoZeile, 7) = .Cells(LoI, 8).Text
ListBox1.List(LoZeile, 8) = .Cells(LoI, 9).Text
ListBox1.List(LoZeile, 9) = .Cells(LoI, 10).Text
LoZeile = LoZeile + 1
End If
Next
End If
End With
End If
End If
Set RaFound = Nothing
Application.ScreenUpdating = True
End Sub
Und so übertrage ich die ListBoxeinträge in die Tabelle:
Private Sub CommandButton10_Click()
Dim n As Long
Dim p As Long
With ThisWorkbook.Worksheets("Tabelle1")
If CBool(ListBox1.ListCount > 0) Then
For n = 0 To ListBox1.ListCount - 1
For p = 0 To ListBox1.ColumnCount - 1
Cells(n + 24, p + 22).Value = CStr(ListBox1.List(n, p))
Next p
Next n
End If
End With
End Sub
Für jede Hilfe vorab vielen Dank !!!
Gruß Andre