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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
Function recherche(mot As String)
Dim newmot As String, i, e, liste
liste = liste & "POSSIBILITé" & vbCrLf
'plage de recherche
fin = Range("a" & Rows.Count).End(xlUp).Row
For Each cell In Range("a2:a" & fin)
'condition sur l'ortographe identique
If cell = mot Then
liste = liste & cell & " enligne " & cell.Row & vbCrLf
GoTo suite
End If
'condition sur l'espacement entre les lettre
If Replace(cell, " ", "") = mot Then
liste = liste & cell & " enligne " & cell.Row & vbCrLf
GoTo suite
End If
'condition sur l'espacement par des point entre les lettres
If LCase(Replace(cell, ".", "")) = mot Then
liste = liste & cell & " enligne " & cell.Row & vbCrLf
GoTo suite
End If
'condition sur l'espacement par des virgules entre les lettres
If Replace(cell, ",", "") = mot Then
liste = liste & cell & " enligne " & cell.Row & vbCrLf
GoTo suite
End If
'condition par les espace et la 1 ere lettre des mots qui composent le nom dans la cellule
If InStr(cell, " ") > 0 Then 'And Len(cell) > Len(mot) Then
multimot = Split(cell, " ")
For e = 0 To UBound(multimot)
newmot = newmot & Left(multimot(e), 1)
Next e
If newmot = mot Then liste = liste & cell & " enligne " & cell.Row & vbCrLf
End If
suite:
newmot = ""
Next
recherche = liste
End Function
Sub test_de_recherche()
MsgBox recherche("agf")
End Sub |
Partager