La formule ne marche plus, voila un example
Cellule P414 (nom): Brasxxxxxxx
Cellule Q414 (prenom): Eric
Dans une des cellule de la colonne I, en I10 j'ai le texte:
"Cotisation Eric Brasxxxxxxx"
Dans ma cellule de calcul:
Formule: =findstr(P414,Q414,I:I)
Resultat: Mot non trouvé
avec ta formule precedente:
Function findstr(mot1 As String, mot2 As String, r As Range) As String
For Each c In r
mottrouvé = sm(UCase(mot1), UCase(c.Value))
If motrouvé Then mottrouvé = sm(UCase(mot2), UCase(Cells(c.Row, "J")))
If mottrouvé Then st = st & sep & c.Address & "; " & Cells(c.Row, "N") & "; " & Cells(c.Row, "O"): If sep = "" Then sep = " - "
Next
If st <> "" Then
findstr = st
Else
findstr = "mot non trouvé"
End If
End Function
Private Function sm(mot, source) As Boolean
q = InStr(source, mot)
mottrouvé = False
If q <> 0 Then
mottrouvé = True
If q + Len(mot) < Len(source) Then
If InStr(" ,.;:-", Mid(source, q + Len(mot), 1)) = 0 Then mottrouvé = False
End If
If q > 1 Then
If InStr(" ,.;:-", Mid(source, q - 1, 1)) = 0 Then mottrouvé = False
End If
End If
sm = mottrouvé
End Function
Pour les memes cellules que precedemment, le resultat etait:
$I$10; 40 EUR; - $I$12; 80 EUR;
Car Brasxxxxx etait dans la cellule I10 et I12. Mais Eric n'est que dans la ligne 10. En ligne 12, c'est le meme nom mais un autre prenom.
Merci