Bonsoir,
Voici un essai avec une fonction qui renvoie un tableau et qui est utiliser au sein de votre macro Nettoie, elle-même appelée par la macro NomsPropres :
Function NETTOYER(PlageAnettoyer, PlageExclusion)
chaine = Join(Application.Transpose(PlageAnettoyer), "~")
motif = Application.Transpose(PlageExclusion)
Set reg = CreateObject("vbscript.regexp")
With reg
.Global = True
.IgnoreCase = True
For i = LBound(motif) To UBound(motif)
.Pattern = "~" & motif(i) & "~"
If .Test(chaine) Then chaine = .Replace(chaine, "~")
Next i
.Pattern = "~+"
chaine = .Replace(chaine, "~")
End With
NETTOYER = Application.Transpose(Split(chaine, "~"))
End Function
Cdlt,