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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
Private Sub UserForm_Activate()
Dim i As Long
Dim x As Integer, DerniereLigne As Integer
Sheets("data_global").Select
'On récupère la dernière ligne de la source de données
If Cells(Rows.Count, 1).End(xlUp).Row = 1 Then
DerniereLigne = 2
Else
DerniereLigne = Cells(Rows.Count, 1).End(xlUp).Row
End If
ListBox1.Clear
'On définit la dimension de nos colonnes
With Me.ListBox1
.ColumnHeads = True
.ColumnWidths = "15;30;100;100;100;100;100;0"
.ColumnCount = 7
.ListStyle = 1
.MultiSelect = 1
End With
'On alimente la list box avec les données qui nous intéressent
For x = 1 To DerniereLigne
If Left(Cells(x, 2), 7) = "Demande" Then
Me.ListBox1.AddItem Cells(x, 1)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = Cells(x, 4)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = Cells(x, 10)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = Cells(x, 11)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 4) = Cells(x, 7)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 5) = Cells(x, 6)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 6) = Cells(x, 8)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 7) = Cells(x, 9)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 8) = Cells(x, 3)
' Me.ListBox1.List(Me.ListBox1.ListCount - 1, 9) = Cells(x, 10)
End If
Next x
For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) = True Then Me.ListBox1.Selected(i) = False
Next i:
End Sub |
Partager