OVH Cloud OVH Cloud

Comment faire une recherche dicothomique?

2 réponses
Avatar
MsNewsMicrosoft.com
Bonjour a tous,
Comment faire une recherche dichotomique sous excel.
Je voudrai pouvoir en tapant quelques lettres afficher la liste des clients
enregistrés et ensuite l'inserer dans une cellule.
Merci a tous

2 réponses

Avatar
Jacky
Bonsoir,
Si c'est pour une recherche Dichotomique ou autre d'ailleurs cela pourrait
ressembler à ceci:
'-------------
Sub ChercheClient()
Dim DerLi&, i&, Libre&, Mot$
Mot = InputBox("Client à chercher :")
If Mot = "" Then Exit Sub
DerLi = Cells(Rows.Count, "A").End(xlUp).Row
For i = DerLi To 3 Step -1
If Application.CountIf _
(Range("A" & i & ":X" & i), "*" & Mot & "*") = 0 Then
Range("A" & i).EntireRow.Hidden = True
End If
Next i
If Cells(Rows.Count, "A").End(xlUp).Row = 1 Then
Cells.EntireRow.Hidden = False
MsgBox "'" & Mot & "' n'a pas été trouvé !"
End If
End Sub
'----------------
Salutations
JJ



"MsNewsMicrosoft.com" a écrit dans le message de
news:
Bonjour a tous,
Comment faire une recherche dichotomique sous excel.
Je voudrai pouvoir en tapant quelques lettres afficher la liste des
clients

enregistrés et ensuite l'inserer dans une cellule.
Merci a tous




Avatar
Jacky
et pour mettre le tout sur une autre feuille(publié sur ce forum)

Sub ChercheEtAutreFeuille()
Dim DerLi&, i&, Libre&, Mot$
Dim Source As Worksheet, Cible As Worksheet

Mot = InputBox("Client à chercher :")
If Mot = "" Then Exit Sub
Set Source = ActiveSheet
Sheets.Add
Set Cible = ActiveSheet
nom = "Resultat sur " & Mot
If Len(nom) > 31 Then
nom = "Resultat sur " & Left(Mot, 18)
End If
'MsgBox Len(nom) & nom
ActiveSheet.Name = nom
'MsgBox ActiveSheet.Name
Cible.Range("A1:X1").Value = Source.Range("A1:X1").Value
DerLi = Source.Cells(Rows.Count, "A").End(xlUp).Row
For i = DerLi To 3 Step -1
If Application.CountIf(Source.Range("A" & i & ":X" & i), "*" & Mot &
"*") > 0 Then
Libre = Cible.Cells(Rows.Count, "A").End(xlUp).Row + 1
Cible.Range("A" & Libre & ":X" & Libre).Value = Source.Range("A" & i &
":X" & i).Value
x = x + 1
End If
Next i
[a1] = "Resultat pour '" & Mot & "' =" & x
If Cible.Cells(Rows.Count, "A").End(xlUp).Row = 1 Then
Application.DisplayAlerts = False
Cible.Delete
Application.DisplayAlerts = True
MsgBox "'" & Mot & "' n'a pas été trouvé !"
End If
End Sub

"Jacky" a écrit dans le message de
news:
Bonsoir,
Si c'est pour une recherche Dichotomique ou autre d'ailleurs cela pourrait
ressembler à ceci:
'-------------
Sub ChercheClient()
Dim DerLi&, i&, Libre&, Mot$
Mot = InputBox("Client à chercher :")
If Mot = "" Then Exit Sub
DerLi = Cells(Rows.Count, "A").End(xlUp).Row
For i = DerLi To 3 Step -1
If Application.CountIf _
(Range("A" & i & ":X" & i), "*" & Mot & "*") = 0 Then
Range("A" & i).EntireRow.Hidden = True
End If
Next i
If Cells(Rows.Count, "A").End(xlUp).Row = 1 Then
Cells.EntireRow.Hidden = False
MsgBox "'" & Mot & "' n'a pas été trouvé !"
End If
End Sub
'----------------
Salutations
JJ



"MsNewsMicrosoft.com" a écrit dans le message de
news:
Bonjour a tous,
Comment faire une recherche dichotomique sous excel.
Je voudrai pouvoir en tapant quelques lettres afficher la liste des
clients

enregistrés et ensuite l'inserer dans une cellule.
Merci a tous