Bonjour,
J'ai un code, qui permet de chercher une valeur dans la colonne 3 onglet Dbase, je souhaite renvoyer la valeur dans une listebox la valeur de la colonne 1 de la feuille Dbase
Cela concerne la combobox 2 et bouton recherche CommandButton1.
Je souhaite afficher l'ensemble des résultats FoundAt dans la listbox.
Si vous avez un avis.
Private Sub CommandButton1_Click()
Dim oRange As Range, aCell As Range, bCell As Range
Dim ws As Worksheet
Dim SearchString As String, FoundAt As String
On Error GoTo Whoa
Set ws = Worksheets("Dbase")
Set oRange = ws.Columns(3)
SearchString = Me.ComboBox2
Set aCell = oRange.Find(What:=SearchString, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not aCell Is Nothing Then
Set bCell = aCell
FoundAt = aCell.Address
Do
Set aCell = oRange.FindNext(After:=aCell)
If Not aCell Is Nothing Then
If aCell.Address = bCell.Address Then Exit Do
FoundAt = FoundAt & ", " & aCell.Address
Else
Exit Do
End If
Loop
Else
MsgBox SearchString & " not Found"
Exit Sub
End If
MsgBox "The Search String has been found these locations: " & FoundAt
Exit Sub
Whoa:
MsgBox Err.Description
End Sub
Merci.