Macro pour faire un mot en gras dans un texte

Bonsoir à tous,

j'ai un fichier où en colonne E je voudrais que le mot "anomalie" se mette en gras

Je souhaiterais le faire avec Vba : la macro sélectionne toutes la colonne E et met en gras le mot "anomalie"

Jespere que quelqu'un pourra m'aider

Bonne soirée à tous

Eno

Bonsoir,

Un début,

Le soucis c'est le mot 'anomalie" présent plusieurs fois sur la même ligne

Sub test()
Dim dl%, i%
dl = Range("e" & Rows.Count).End(xlUp).Row
  For i = 1 To dl
    If Cells(i, 5) Like "*anomalie*" Then
      Cells(i, 5).Characters(InStr(1, Cells(i, 5).Value, "anomalie"), Len("anomalie")).Font.Bold = True
    End If
  Next i
End Sub

Bonsoir,

Sub AnomalieGras()
    Dim c As Range, h%
    With ActiveSheet.UsedRange
        For Each c In .Columns("E").Cells
            If c <> "" Then
                h = InStr(1, c, "anomalie", vbTextCompare)
                If h > 0 Then
                    Do
                        c.Characters(h, 8).Font.Bold = True
                        h = InStr(h + 8, c, "anomalie", vbTextCompare)
                    Loop While h > 0
                End If
            End If
        Next c
    End With
End Sub

Cordialement.

edit : Salut M12

Bonsoir à vous deux!

Le code fonctionne parfaitement

merci à vous!

Tres bonne soirée

Rechercher des sujets similaires à "macro mot gras texte"