ich benötige eure Hilfe.
Mit nachstehendem Code fülle ich die ListBox1:
<pre>Sub Listbox1_fuellen()
Dim i As Long
Dim str, ii, arr, str2, maxlen, LC
Dim Li
maxlen = 35 'maximale Länge der Zelle für Vorgang
With ListBox1
.Clear
.ColumnCount = 9 '8Spalten erforderlich für Zeilen
.ColumnWidths = "3cm;6cm;3cm;3cm;3cm;3cm;3cm;0cm;0cm" 'durch letzte beide 0cm werden die beiden letzten Spalten ausgeblendet
For i = 9 To Cells(Rows.Count, "B").End(xlUp).Row
Li = i - 9
str = Cells(i, 3)
.AddItem
LC = .ListCount - 1
.List(LC, 0) = Cells(i, 2) 'SpalteA in Spalte1
.List(LC, 1) = Cells(i, 3) 'Original-Text speichern
.List(LC, 2) = Cells(i, 4) 'SpalteD in dritte Spalte3
.List(LC, 3) = Cells(i, 5) 'SpalteD in dritte Spalte3
.List(LC, 4) = Format(Cells(i, 6), "#,##0.00 ") 'SpalteE in dritte Spalte4
.List(LC, 5) = Format(Cells(i, 7), "#,##0.00 ") 'SpalteF in dritte Spalte5
.List(LC, 6) = Format(Cells(i, 8), "#,##0.00 ") 'SpalteG in dritte Spalte6
.List(LC, 7) = Li 'Zeilen-Nr speichern
.List(LC, 8) = Cells(i, 3) 'Original-Text speichern
str = Cells(i, 3)
If i > 9 Then
If str = "" Then str = " "
arr = Split(str, " ")
str2 = arr(0)
For ii = 1 To UBound(arr)
If Len(str2 & arr(ii)) + 1 <= maxlen Then
str2 = str2 + " " + arr(ii)
Else
.AddItem
LC = .ListCount - 1
'.List(LC, 0) = Cells(i, 2) 'SpalteA in Spalte1
.List(LC, 1) = Cells(i, 3) 'Original-Text speichern
'.List(LC, 2) = Cells(i, 4) 'SpalteD in dritte Spalte3
'.List(LC, 3) = Format(Cells(i, 5), "#,###.00 ") 'SpalteE in dritte Spalte4
'.List(LC, 4) = Format(Cells(i, 6), "#,###.00 ") 'SpalteF in dritte Spalte5
'.List(LC, 5) = Format(Cells(i, 7), "#,###.00 ") 'SpalteG in dritte Spalte6
' .List(LC, 6) = Li 'Zeilen-Nr speichern
' .List(LC, 7) = Cells(i, 3) 'Original-Text speichern
.List(LC, 7) = Li 'Zeilen-Nr speichern
.List(LC, 8) = Cells(i, 3) 'Original-Text speichern
str2 = arr(ii)
End If
.List(.ListCount - 1, 1) = str2
Next ii
End If
Next i
End With
End Sub</pre>
Wie kann ich in der Userform den letzten Eintrag anzeigen, jedoch nicht markieren?
Besten Dank für eure Hilfe.
Gruss
Peter