Private Sub CommandButton1_Click()
' Recherche
Dim Cel2 As Range
Dim Colonne As Integer, Indice As Integer
Dim Ligne As Long
Dim WsSource As Worksheet, WsCible As Worksheet
'Récupération des informations
Workbooks("SOURCE").Activate
Set WsSource = ActiveSheet
If Me.TextBox2 = "" Then
MsgBox "Veuillez indiquer le nom à rechercher !"
Exit Sub
End If
With WsSource
Set Cel2 = .Columns(3).Find(what:=Me.TextBox2, LookIn:=xlValues, lookat:=xlWhole)
If Not Cel2 Is Nothing Then
Colonne = Cel2.Column
Else
MsgBox "Le collaborateur " & TextBox1 & " - " & TextBox2 & " n'a pas été trouvé dans la liste."
Exit Sub
End If
For Ligne = 1 To 20000
If .Cells(Ligne, Colonne) = Me.TextBox2 Then
Me.ListBox1.AddItem .Range("C" & Ligne)
Me.ListBox1.List(Indice, 1) = .Range("D" & Ligne)
Indice = Indice + 1
End If
Next Ligne
End With
End Sub