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
|
Private Sub CommandButton1_Click()
UserForm1.ListBox1.ColumnCount = 2
UserForm1.ListBox1.ColumnWidths = "120;120"
Dim chercher As String
Dim limit As Long, ligneu As Long
Dim msg
chercher = TextBox1.Text
ligneu = Feuil1.Columns(1).Find("" & chercher, [A1], , , xlByRows, xlNext).Row
msg = Feuil1.Cells(ligneu, 1)
UserForm1.ListBox1.AddItem msg
UserForm1.ListBox1.List(0, 1) = Feuil1.Cells(ligneu, 2)
limit = 100
Do While ligneu < limit
vl = ligneu
ligneu = Feuil1.Columns(1).FindNext(after:=Cells(vl, 1)).Row
If ligneu < vl Or ligneu = vl Then Exit Do
msg = Feuil1.Cells(ligneu, 1)
UserForm1.ListBox1.AddItem Feuil1.Cells(ligneu, 1)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1, 1) = Feuil1.Cells(ligneu, 2)
Loop
End Sub |
Partager