AW: Das funzt soweit aber?
25.08.2005 13:25:43
Sylvio
Hello again,
wie gesagt ich habs mit deiner Variante 2 versucht und hab folgendes zusammengeschustert.
Zuvor paar Erklärungen also ArtikelID ist ne Combobox
Anzeige ist ne Listbox
notmarketed() ist mein Feld
i und j sind Laufparameter
ich nehme also den Wert aus dem Feld und schreib ihn unten rechts Cells(65536, 256)
rein, guckt ja keiner hin da.
mache Autofit nehme amschließend den Breitenwert der Spalte
und rechne ihn anhand einer formel die ich im Netz gefunden habe um in cm.
.ColumnWidth + 0.71) / 5.1425
zum Glück kann mann ColumnWidths in cm angeben, da ich die umrechnung von Punkt in cm nicht weiß. Das Ganze ist nicht hundert prozent deshalb die Korekturfaktoren bei ColumnsWidths. Bei sehr großem Text, wie bei mir bei tmpSize2, wird die Spalte etwas zu
groß, da ich aber auch kurzen Text habe kann ich keinen Verkürzungsfaktor nehmen da sonst wieder Teile fehlen.
Dann noch das ganze von cm in Pixel + Korrekturfaktor
und fertig ist die gesamtbreite der Listbox .Width = tmpholesize
Private Sub ArtikelID_Change()
Dim tmpSize As Double
Dim tmpSize2 As Double
Dim tmpSize3 As Double
Dim tmpholesize As Double
Dim number
Anzeige.Clear
number = "7302471612" 'ArtikelID.Text
i = 0
Do While number <> notmarketed(0, i)
i = i + 1
Loop
With Anzeige
.ColumnCount = 3
.AddItem
Application.ActiveWorkbook.ActiveSheet.Cells(65536, 256).Value = notmarketed(0, i)
Application.ActiveWorkbook.ActiveSheet.Cells(65536, 256).Columns.AutoFit
tmpSize = (Application.ActiveWorkbook.ActiveSheet.Cells(65536, 256).ColumnWidth + 0.71) / 5.1425
Application.ActiveWorkbook.ActiveSheet.Cells(65536, 256).Value = notmarketed(1, i)
Application.ActiveWorkbook.ActiveSheet.Cells(65536, 256).Columns.AutoFit
tmpSize2 = (Application.ActiveWorkbook.ActiveSheet.Cells(65536, 256).ColumnWidth + 0.71) / 5.1425
Application.ActiveWorkbook.ActiveSheet.Cells(65536, 256).Value = notmarketed(2, i)
Application.ActiveWorkbook.ActiveSheet.Cells(65536, 256).Columns.AutoFit
tmpSize3 = (Application.ActiveWorkbook.ActiveSheet.Cells(65536, 256).ColumnWidth + 0.71) / 5.1425
Application.ActiveWorkbook.ActiveSheet.Cells(65536, 256).Clear
.ColumnWidths = tmpSize + 0.05 & " cm;" & tmpSize2 & " cm;" & tmpSize3 + 0.05 & " cm"
tmpholesize = (((tmpSize + 0.05 + tmpSize2 + tmpSize3 + 0.05) * 10) / 0.376) + 30
.Width = tmpholesize
.List(.ListCount - 1, 0) = notmarketed(0, i)
.List(.ListCount - 1, 1) = notmarketed(1, i)
.List(.ListCount - 1, 2) = notmarketed(2, i)
End With
End Sub
Ich bräuchte halt ne genau Umrechnung von Zellenbreite in cm
und für die Listbox von Punkt (pt) in cm da hätte ich es exakter
oder nochbesser der Wert im Feld also der String als Punkt (pt) für die Listbox
Wenn Du was darüber weißt immer her damit.
Gruß Sylvio