1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Dim NbCol
Private Sub UserForm_Initialize()
NbCol = [tableau1].Columns.Count
Me.ListBox1.ColumnCount = NbCol
tblBD = [tableau1]
For i = 1 To UBound(tblBD): tblBD(i, 4) = Format(tblBD(i, 4), "0000.00"): Next i
Me.ListBox1.List = tblBD
EnteteListBox
End Sub
Sub EnteteListBox()
x = Me.ListBox1.Left + 8
Y = Me.ListBox1.Top - 12
For i = 1 To NbCol
Set lab = Me.Controls.Add("Forms.Label.1")
lab.Caption = [tableau1].Offset(-1).Cells(1, i)
lab.Top = Y
lab.Left = x
x = x + [tableau1].Columns(i).Width * 1.1
temp = temp & [tableau1].Columns(i).Width * 1.1 & ";"
Next
temp = Left(temp, Len(temp) - 1)
Me.ListBox1.ColumnWidths = temp
End Sub |
Partager