Listbox füllen
26.11.2025 16:28:25
Dirk
habe folgendes Problem : Ich möchte eine Listbox mit 11 Spalten füllen,
angezeigt werden in der Listbox aber nur 2 Spalten. Kriege es allein nicht hin.
Über eine Lösung würde ich mich freuen und bedanke mich schon mal im Voraus.
Grüße
Dirk
Option Explicit
Private Sub UserForm_Initialize()
Dim i As Long
Dim ws As Worksheet
Dim lastRow As Long
Dim startRow As Long
Set ws = ThisWorkbook.Sheets("Lizenz")
startRow = 2
lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
With Me
.BackColor = RGB(211, 211, 211)
.Height = 290
.Width = 480
.StartupPosition = 2
.Caption = "Mandanten auswählen"
End With
With Me.Label1
.BackStyle = 0
.Font.Size = 10
.Font.Bold = True
.TextAlign = 1
.ForeColor = RGB(0, 0, 0)
.Caption = "Bitte wählen Sie einen Mandanten aus !"
End With
With Me.ListBox1
.Clear
.ColumnCount = 11
.ColumnWidths = "2cm;3cm;3cm;5cm;3cm;3cm;5cm;5cm;5cm;4cm;5cm"
End With
For i = startRow To lastRow
With Me.ListBox1
.AddItem ws.Cells(i, 1).Value
.List(.ListCount - 1, 1) = ws.Cells(i, 2).Value
End With
Next i
End Sub
Anzeige