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
| Sub libertéVert()
Dim Plage As Range, Cel As Range
Dim LeMot As String, AdrDeb As String
' --------------------------------------------
'A adapter en fonction du mot voulu Et de la Plage voulue
Set Plage = Sheets("Feuil1").Range("A1:Z2000")
LeMot = "liberté"
' --------------------------------------------
With Plage
Set Cel = .Find(LeMot, LookAt:=xlPart)
If Not Cel Is Nothing Then
AdrDeb = Cel.Address
Do
Modif Cel, LeMot
Set Cel = .FindNext(Cel)
Loop While Not Cel Is Nothing And AdrDeb <> Cel.Address
End If
End With
End Sub
Private Sub Modif(ByRef Cel As Range, LeMot)
Dim T As String
Dim Pos As Integer
T = Cel.Text
Do
'Respecte la casse Majuscule/Minuscule -------
Pos = InStr(Pos + 1, T, LeMot)
' Ne tient pas compte des Majuscule/Minuscule-
Pos = InStr(Pos + 1, T, LeMot, vbTextCompare)
' --------------------------------------------
If Pos > 0 Then
With Cel.Characters(Start:=Pos, Length:=Len(LeMot)).Font
.FontStyle = "Gras"
.ColorIndex = 4 'VERT
End With
End If
Loop Until Pos = 0
End Sub |
Partager