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


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
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.
    Sherry Fox · 4 months ago
    I attempted to run this code and just got an error..."Compile Error: Wrong # of arguments or invalid property assignment". Below is the image of the error message and the breakpoint of the code.
    • To post as a guest, your comment is unpublished.
      skyyang · 4 months ago
      Hello, Sherry,
      I can not see your screenshot, please upload it again.
      Thank you!
  • To post as a guest, your comment is unpublished.
    Pedro Martins · 1 years 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 · 2 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 · 2 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 · 1 years 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)