Private Sub CommandButton100_Click()
Dim i As Long, j As Integer
Dim S As String
Dim ColVisu As Variant, Forma, TP, Taille
Dim rs As Object ' Objet Recordset:TP
ColVisu = Array(1, 2, 6): Forma = Array("YYYY-MM-DD", "@", "#,##0.00"): TP = Array(7, 200, 14)
' Créer un objet Recordset
Set rs = CreateObject("ADODB.Recordset")
' Définir les colonnes du Recordset
With rs
For j = 0 To UBound(ColVisu)
.Fields.Append "Colonne" & j, TP(j), 255
Next
.Open
End With
' Parcourir le ListBox et ajouter les lignes qui contiennent "e" dans la colonne 9
With Me.ListBox1
For i = 0 To .ListCount - 1
' If InStr(1, .List(i, 9), Trim(S), vbTextCompare) > 0 Then
rs.AddNew
For j = 0 To UBound(ColVisu)
rs(j) = Format(.List(i, ColVisu(j)), Forma(j))
Next
' End If
Next i
End With
Dim varArray() As Variant
With rs
If Not .EOF Then
.MoveFirst
Range("K2").CopyFromRecordset rs
.MoveFirst
ListBox2.ColumnCount = .Fields.Count
ListBox2.BoundColumn = .Fields.Count
ListBox2.ColumnWidths = "60;80;80"
ListBox2.List = Application.Transpose(.getrows)
End If
End With
rs.MoveLast
n = rs.RecordCount
rs.MoveFirst
varArray() = rs.getrows(n)
With ListBox3
For i = 0 To n - 1
'ListBox3.AddItem varArray(0, i) & ";" & varArray(1, i)
.AddItem varArray(0, i)
.List(.ListCount - 1, 1) = varArray(1, i)
.List(.ListCount - 1, 2) = varArray(2, i)
Next
End With
Set rs = Nothing
End Sub