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
| Private Sub ComboBox1_Click()
Dim F As Worksheet, bd As Variant, i As Integer, temp As Variant
Me.TextBox1.Value = Me.ComboBox1.Text
Me.ListBox1.Clear
Set F = Sheets(Me.TextBox1.Text)
bd = F.Range("F9:J" & F.[F65000].End(xlUp).Row).Value2 ' tableau bd(n,1) pour rapidité
For i = LBound(bd) To UBound(bd)
If bd(i, 1) <> "" Then Call AddArrayElm(temp, Array(bd(i, 1), bd(i, 3), bd(i, 4), bd(i, 5)))
Next i
Me.ListBox1.ColumnCount = 4
Me.ListBox1.List = Application.Transpose(temp)
Private Sub AddArrayElm(Arr As Variant, Elm As Variant)
Dim i As Long, nRow As Long, nCol As Long
nCol = UBound(Elm)
If Not IsArray(Arr) Then
nRow = 0
ReDim Arr(nCol, nRow)
Else
nRow = UBound(Arr, 2) + 1
For i = 0 To nRow - 1
If Elm(0) = Arr(0, i) Then Exit Sub
Next i
ReDim Preserve Arr(nCol, nRow)
End If
For i = 0 To nCol
Arr(i, nRow) = Elm(i)
Next i
End Sub |
Partager