1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| Private Sub UserForm_Initialize()
Dim i As Integer
Dim c
Dim f As Worksheet
With UserForm1
Me.ListBox1.Clear
.ListBox1.ColumnCount = 4
.ListBox1.ColumnWidths = "80;50;50;50"
.ListBox1.MultiSelect = fmMultiSelectMulti
Set f = Sheets("Feuil1")
For Each c In f.Range("A1:A" & f.[a650].End(xlUp).Row)
i = i + 1
.ListBox1.AddItem c
If InStr(c.Offset(0, 1).NumberFormat, "Heures") > 0 Then
.ListBox1.List(i - 1, 1) = Format(c.Offset(0, 1).Value, "0 ""Heures""")
ElseIf InStr(c.Offset(0, 1).NumberFormat, "mètres") > 0 Then
.ListBox1.List(i - 1, 1) = Format(c.Offset(0, 1).Value, "0 ""mètres""")
ElseIf InStr(c.Offset(0, 1).NumberFormat, "fois") > 0 Then
.ListBox1.List(i - 1, 1) = Format(c.Offset(0, 1).Value, "0 ""fois""")
End If
.ListBox1.List(i - 1, 2) = Format(c.Offset(0, 2).Value, "0.00") 'format nombre
.ListBox1.List(i - 1, 3) = Format(c.Offset(0, 3).Value, "0") 'format standard
Next
End With
End Sub |
Partager