Excel vba set bold specific text of string into the cell?

Viewed 80979

I want to set bold some text in string.How can i do it ?

4 Answers

Try this if you need to bold multiple specific text:

Sub Find_and_Bold()
Dim rCell As Range, sToFind As String, iSeek As Long
Dim Text(1 To 4) As String
Dim i As Integer


Text(1) = "text1"
Text(2) = "text2"
Text(3) = "text3"
Text(4) = "text4"


For Each rCell In Range("C7:C1000")
    For i = LBound(Text) To UBound(Text)
            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 i
Next rCell

End Sub

The source for this solution is from: http://www.vbaexpress.com/forum/showthread.php?52245-Make-specific-text-bold-in-cells

Related