Fülle meine Listbox mit fogenden Code , nun meine Frage , gibt es eine möglichkeit die Zeilenanzahl in der
Listbox an der Zeilenanzahl des Tabellenblatt anzupassen . Z.B wenn ich 45 belegte Zeilen habe das die Listbox variabel darauf reagiert , oder muss ich das jedesmal anpassen ?
Public Sub UF3ListBox1Füllen()
Dim lnglast
Dim lngRow
UserForm3.ListBox1.Clear
UserForm3.ListBox1.ColumnCount = 10
UserForm3.ListBox1.ColumnWidths = "80;70;90;100;140;70;70;80;130;60"
UserForm3.ListBox1.TextAlign = fmTextAlignLeft
With ActiveSheet
lnglast = Application.Max(30, .Cells(Rows.Count, 1).End(xlUp).Row)
For lngRow = 2 To lnglast
UserForm3.ListBox1.AddItem .Cells(lngRow, 20)
UserForm3.ListBox1.List(UserForm3.ListBox1.ListCount - 1, 1) = .Cells(lngRow, 21)
UserForm3.ListBox1.List(UserForm3.ListBox1.ListCount - 1, 2) = .Cells(lngRow, 23)
UserForm3.ListBox1.List(UserForm3.ListBox1.ListCount - 1, 3) = .Cells(lngRow, 24) & " " & .Cells(lngRow, 25)
UserForm3.ListBox1.List(UserForm3.ListBox1.ListCount - 1, 4) = .Cells(lngRow, 26) & " " & .Cells(lngRow, 27)
UserForm3.ListBox1.List(UserForm3.ListBox1.ListCount - 1, 5) = .Cells(lngRow, 28)
UserForm3.ListBox1.List(UserForm3.ListBox1.ListCount - 1, 6) = .Cells(lngRow, 29)
UserForm3.ListBox1.List(UserForm3.ListBox1.ListCount - 1, 7) = .Cells(lngRow, 31)
UserForm3.ListBox1.List(UserForm3.ListBox1.ListCount - 1, 8) = .Cells(lngRow, 33)
UserForm3.ListBox1.List(UserForm3.ListBox1.ListCount - 1, 9) = .Cells(lngRow, 38)
Next
UserForm3.ListBox1.ListIndex = 0
End With
Gruss Ralf