Hello,
I have found this code to find and bold specific words in my excel worksheet. The code works good with the 9 first words, however, if I add words based on cell value (text 10 and 11), the code seems to run endlessly and ultimately crashes. The line here seems to be the problem if I debug it " rCell.Characters(iSeek, Len(sToFind)).Font.bold = True". I'm really no expert and I hope someone can help me with this
thank you
I have found this code to find and bold specific words in my excel worksheet. The code works good with the 9 first words, however, if I add words based on cell value (text 10 and 11), the code seems to run endlessly and ultimately crashes. The line here seems to be the problem if I debug it " rCell.Characters(iSeek, Len(sToFind)).Font.bold = True". I'm really no expert and I hope someone can help me with this
thank you
VBA Code:
Sub Find_and_Bold1HAP()
Dim rCell As Range, sToFind As String, iSeek As Long
Dim Text(1 To 11) As String
Dim i As Integer
Dim ws As Worksheet
Set ws = Worksheets("Rapport ini")
Text(1) = "DOSSIER : "
Text(2) = "NOM, PRÉNOM :"
Text(3) = "DATE DE NAISSANCE :"
Text(4) = "Programme :"
Text(5) = "ÂGE :"
Text(6) = "SEXE :"
Text(7) = "TÉLÉPHONE :"
Text(8) = "ADRESSE :"
Text(9) = "Commentaires :"
Text(10) = Worksheets("Données").Range("D211").Text
Text(11) = Worksheets("Données").Range("E211").Text
For i = LBound(Text) To UBound(Text)
For Each rCell In ws.Range("A1:S10, A54, A69, A72, A91")
sToFind = Text(i)
iSeek = InStr(1, rCell.Value, sToFind)
Do While iSeek > 0
rCell.Characters(iSeek, Len(sToFind)).Font.bold = True
iSeek = InStr(iSeek + 1, rCell.Value, sToFind)
Loop
Next rCell
Next i
End Sub