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 CommandButton1_Click()
Dim Tabl(), Ctr As Long
If Me.ComboBox1.ListIndex > -1 Then
Ctr = -1
ReDim Tabl(3, 0)
With Sheets("Sorties")
Set Plage = .Range("B2", .Cells(.Rows.Count, 2).End(xlUp))
End With
For Each C In Plage
If C.Value = Me.ComboBox1.Value Then
Ctr = Ctr + 1
ReDim Preserve Tabl(3, Ctr)
Tabl(0, Ctr) = C.Offset(, -1).Value
Tabl(1, Ctr) = C.Offset(, 1).Value
Tabl(2, Ctr) = C.Offset(, 2).Value
Tabl(3, Ctr) = C.Offset(, 3).Value
End If
Next C
With Me.ListBox1
If UBound(Tabl, 2) > 0 Then
.List = Application.Transpose(Tabl)
Else
.AddItem Tabl(0, 0)
.List(.ListCount - 1, 1) = Tabl(1, 0)
.List(.ListCount - 1, 2) = Tabl(2, 0)
.List(.ListCount - 1, 3) = Tabl(3, 0)
End If
End With
End If
End Sub |
Partager