Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to bold all specific words in a range of cells?

doc bold specifc text 1

In Excel, the Find and Replace function can help us to find any specific text and give a bold or any other formatting for the entire cells. But, have you ever tried to bold only the specific text in cells not the whole cell as below screenshot shown:

Bold all specific words in a range of cells with VBA code


arrow blue right bubble Bold all specific words in a range of cells with VBA code


The following VBA code may help you to bold only the specific text in a cell content, please do as follows:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Bold specific text in a range of cells

Sub FindAndBold()
'Updateby Extendoffice 20160711
    Dim xFind As String
    Dim xCell As Range
    Dim xTxtRg As Range
    Dim xCount As Long
    Dim xLen As Integer
    Dim xStart As Integer
    Dim xRg As Range
    Dim xTxt As String
    On Error Resume Next
    If ActiveWindow.RangeSelection.Count > 1 Then
      xTxt = ActiveWindow.RangeSelection.AddressLocal
    Else
      xTxt = ActiveSheet.UsedRange.AddressLocal
    End If
    Set xRg = Application.InputBox("Please select data range:", "Kutools for Excel", xTxt, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    On Error Resume Next
    Set xTxtRg = Application.Intersect(xRg.SpecialCells(xlCellTypeConstants, xlTextValues), xRg)
    If xTxtRg Is Nothing Then
        MsgBox "There are no cells with text"
        Exit Sub
    End If
    xFind = Trim(Application.InputBox("What do you want to BOLD?", "Kutools for Excel", , , , , , 2))
    If xFind = "" Then
        MsgBox "No text was listed", vbInformation, "Kutools for Excel"
        Exit Sub
    End If
    xLen = Len(xFind)
    For Each xCell In xTxtRg
        xStart = InStr(xCell.Value, xFind)
        Do While xStart > 0
            xCell.Characters(xStart, xLen).Font.Bold = True
            xCount = xCount + 1
            xStart = InStr(xStart + xLen, xCell.Value, xFind)
        Loop
    Next
    If xCount > 0 Then
        MsgBox "number of " & CStr(xCount) & " text be bolded!", vbInformation, "Kutools for Excel"
    Else
        MsgBox "Not find the specific text!", vbInformation, "Kutools for Excel"
    End If
End Sub

3. Then press F5 key to run this code, and a prompt box is popped out to remind you select the data range that you want to bold, see screenshot:

doc bold specifc text 2

4. And then click OK, another box will pop out to remind you entering the specific text that you want to bold only in cells, see screenshot:

doc bold specifc text 3

5. After entering the text, please click OK button, and all the text that you specified has been bolded in the selected range, see screenshot:

doc bold specifc text 4


Excel Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 70%, and Help You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for you.

  • Designed for 1500+ work scenarios, helps you solve 80% Excel problems.
  • Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  • Being used by 110,000 elites and 300+ well-known companies.

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Pedro Martins · 10 months ago
    Hello, its possible to search multiple text and bold that text PLUS that cell line. (I have 1 cell with 5 lines, i want to bold the line if find "1º", if rest like "2º" "3º" , "number + º " bold only number.)

    Other need is:
    If find "1º" bold that cell line
  • To post as a guest, your comment is unpublished.
    ERIC ARIAS · 1 years ago
    Can this VBA be modified to bold multiple texts, such as "KTE", "KTO", and "KTW"?
    • To post as a guest, your comment is unpublished.
      skyyang · 1 years ago
      Hello, Eric,

      May be the following VBA code can help you to bold multiple specific cell, please apply the below code.
      Sub FindAndBold()
      Dim I As Long
      Dim xFind As String
      Dim xCell As Range
      Dim xTxtRg As Range
      Dim xCount As Long
      Dim xLen As Integer
      Dim xStart As Integer
      Dim xRg As Range, xRgFind As Range
      Dim xTxt As String
      Dim xArr() As String
      On Error Resume Next
      If ActiveWindow.RangeSelection.Count > 1 Then
      xTxt = ActiveWindow.RangeSelection.AddressLocal
      Else
      xTxt = ActiveSheet.UsedRange.AddressLocal
      End If
      Set xRg = Application.InputBox("Please select data range:", "Kutools for Excel", xTxt, , , , , 8)
      If xRg Is Nothing Then Exit Sub
      On Error Resume Next
      Set xTxtRg = Application.Intersect(xRg.SpecialCells(xlCellTypeConstants, xlTextValues), xRg)
      If xTxtRg Is Nothing Then
      MsgBox "There are no cells with text"
      Exit Sub
      End If
      Set xRgFind = Application.InputBox("Select the text cells you want to bold", "Kutools for Excel", , , , , , 8)
      If xRgFind Is Nothing Then
      MsgBox "No text was listed", vbInformation, "Kutools for Excel"
      Exit Sub
      End If
      ReDim xArr(xRgFind.Count - 1)
      For I = 0 To (xRgFind.Count - 1)
      xArr(I) = xRgFind(I + 1)
      Next
      For Each xCell In xTxtRg
      For I = 0 To UBound(xArr)
      xFind = Trim(xArr(I))
      xStart = InStr(xCell.Value, xFind)
      xLen = Len(xFind)
      Do While xStart > 0
      xCell.Characters(xStart, xLen).Font.Bold = True
      xCount = xCount + 1
      xStart = InStr(xStart + xLen, xCell.Value, xFind)
      Loop
      Next
      Next
      If xCount > 0 Then
      MsgBox "number of " & CStr(xCount) & " text be bolded!", vbInformation, "Kutools for Excel"
      Else
      MsgBox "Not find the specific text!", vbInformation, "Kutools for Excel"
      End If
      End Sub

      Hope it can help you, thank you!
      • To post as a guest, your comment is unpublished.
        Pedro Martins · 10 months ago
        Hello skyyang, can you help me out in my excel?
        If find "1º" in a cell with several lines, bold that cell line
      • To post as a guest, your comment is unpublished.
        ilie neagu · 1 years ago
        if I want to make bold the string G-AD only it doesn t work if i have in my cell G-AD and G-AD-bla-bla-bla (this G-AD should not be made BOLD)