UF-Listbox Spaltenbreite
09.11.2013 13:26:38
chrissi
ich möchte die Spaltenbreite einer Listbox automatisch festlegen.
In meinem Beispiel ist die Breite der Spalte A = 54
in Spalte B = 159,25
Jedoch werden die Breiten der Userform Listbox nicht geändert.
Danke, für Eure Hilfe.
Gruß, Chrissi
Private Sub CMD_K1_Click
Dim ii as Long, Endrow as Long
Dim strBreite As String
Dim strBreite1 As String
Dim A As Double, B As Double
Dim xSuch As String
Dim Spalte As Integer
LstK1.Clear
Spalte = 9
xSuch = "Firma"
With Workbooks("V4_Dat.xlsx").Worksheets("Kunden")
.Activate
.Cells.Select
.Cells.EntireColumn.AutoFit
Range("A1").Select
Endrow = .Cells(Rows.Count, 1).End(xlUp).Row
For ii = 2 To Endrow
If .Cells(ii, Spalte) = xSuch Then
LstK1.AddItem Cells(ii, 1).Value
LstK1.List(LstK1.ListCount - 1, 0) = .Cells(ii, 1).Value
LstK1.List(LstK1.ListCount - 1, 1) = .Cells(ii, 2).Value
End If
Next ii
strBreite = .Columns(1).Width
strBreite1 = .Columns(2).Width
A = strBreite
B = strBreite1
LstK1.ColumnWidths = "A ; B"
End Sub