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 32 33 34 35 36
|
Private Sub CommandButton1_Click()
UserForm1.ListBox1.Clear
UserForm1.ListBox1.ColumnCount = 2
UserForm1.ListBox1.ColumnWidths = "120;120"
Dim chercher As String, NomTemp As String
Dim AncienneLigne As Long, NouvelleLigne As Long
chercher = TextBox1.Text
Set cherche = Feuil1.Columns(1).Find("" & chercher, [A1], , , xlByRows, xlNext)
If cherche Is Nothing Then
MsgBox "Aucun résultat"
Else
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
ok = "[A" & vl & "]"
'MsgBox ok
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 If |
Partager