Option Explicit
Sub ColorerMot_v4()
Dim p, m, dico, i&, s, n&, j&, deb&, Ti, txt, aSuppr As Boolean, xrg As Range, nbMots, ColonneSupp As Boolean
Ti = Timer
Application.ScreenUpdating = False
Application.StatusBar = "Raz des formats en colonne B..."
Intersect(UsedRange, Range("b:b")).Font.Bold = False
Intersect(UsedRange, Range("b:b")).Font.ColorIndex = xlColorIndexAutomatic
Application.StatusBar = "Lecture des mots et phrases..."
m = Range("a1:b" & Cells(Rows.Count, "a").End(xlUp).Row)
p = Range("b1:b" & Cells(Rows.Count, "b").End(xlUp).Row)
Set dico = CreateObject("scripting.dictionary")
dico.CompareMode = vbTextCompare
For i = 1 To UBound(m): dico(m(i, 1)) = "": Next
Application.StatusBar = "Début de l'analyse et formatage des phrases..."
For i = 1 To UBound(p)
aSuppr = True
s = Split(p(i, 1)): deb = 1
For j = 0 To UBound(s)
nbMots = nbMots + 1
txt = s(j)
If Right(txt, 1) = "." Or Right(txt, 1) = "," Or Right(txt, 1) = ";" Then txt = Left(txt, Len(txt) - 1)
If Right(txt, 1) = ":" Or Right(txt, 1) = "!" Or Right(txt, 1) = "?" Then txt = Left(txt, Len(txt) - 1)
If Right(txt, 1) = ")" Or Right(txt, 1) = "-" Or Right(txt, 1) = "]" Then txt = Left(txt, Len(txt) - 1)
If Right(txt, 1) = """" Or Right(txt, 1) = "'" Or Right(txt, 1) = "_" Then txt = Left(txt, Len(txt) - 1)
If dico.Exists(txt) Then
aSuppr = False
Cells(i, "b").Characters(Start:=deb, Length:=Len(txt)).Font.Bold = True
Cells(i, "b").Characters(Start:=deb, Length:=Len(txt)).Font.Color = RGB(0, 0, 255)
End If
deb = deb + Len(s(j)) + 1
Next j
If aSuppr Then p(i, 1) = CVErr(xlErrNA) Else p(i, 1) = Empty
If i Mod 500 = 0 Then Application.StatusBar = "Phrase " & i & " / " & UBound(p)
Next i
'suppression en masse
Application.StatusBar = "Suppression en cours -> insertion colonne..."
On Error GoTo Pas2Colonne
Columns(3).Insert: ColonneSupp = True
With Columns(3).Resize(UBound(p))
Application.StatusBar = "Suppression en cours -> remplissage colonne..."
.Value = p
Application.StatusBar = "Suppression en cours -> tri..."
.Offset(, -1).Resize(, 2).Sort key1:=Cells(1, 3), order1:=xlAscending
Application.StatusBar = "Suppression en cours -> suppression des lignes..."
.SpecialCells(xlCellTypeConstants, xlErrors).Offset(, -1).EntireRow.Delete xlShiftUp
Application.StatusBar = "Suppression en cours -> collage valeurs en colonne A..."
Range("a1").Resize(UBound(m)) = m
End With
Pas2Colonne:
On Error GoTo 0
If ColonneSupp Then Columns(3).Delete
Application.StatusBar = False
MsgBox "C'est terminé! Durée= " & Format(Timer - Ti, "0.0\ sec.") & _
vbLf & UBound(p) & " phrases traitées contenant " & Format(nbMots, "0,000") & " mots.", vbInformation
End Sub