Private Sub UserForm_Initialize()
Dim Lgn As Integer
Dim LastLig As Long
Dim Col As Byte
Dim LastCol As Byte
Dim x As Integer
Dim Tab_Recup As Variant
Dim Tab_Recap() As Variant
DTPicker1.Value = Now()
x = 0
With Me.ListBox1
.ColumnCount = 11 'on definie le nombre de colonne de la ListBox
.ColumnWidths = "90;70;50;50;50;50;90;70;90;90;90" 'on définie la largeur des colonnes
End With
With Worksheets("Programacao") 'avec la feuille
LastLig = .Cells(.Rows.Count, 2).End(xlUp).Row 'on détermine la dernière ligne non vide de la page de données
LastCol = .Cells(2, .Columns.Count).End(xlToLeft).Column 'ici la dernière colonne
Tab_Recup = .Range(.Cells(3, 2), .Cells(LastLig, LastCol)).Value 'on remplie le tableau des donnees de la plage ainsi définie
End With
For Lgn = 1 To UBound(Tab_Recup, 1) 'pour chaque ligne du tableau
If Tab_Recup(Lgn, 11) = "" Then 'si colonne 11 vide alors
ReDim Preserve Tab_Recap(11, x) 'on redimensionne le tableau temporaire
For Col = 1 To UBound(Tab_Recup, 2) - 1 'pour chaque colonne du Tableau de s données
Tab_Recap(Col, x) = Tab_Recup(Lgn, Col) 'on colle les valeurs
Next Col 'autre colonne
x = x + 1 'on incremente
End If
Next Lgn
With Me.ListBox1 'avec la listBox
.Clear 'on l'efface
.List = Application.Transpose(Tab_Recap) 'on colle le tableau temporaire
End With
End Sub