Skip to main content

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

Author: Xiaoyang Last Modified: 2016-07-15
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
      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)
    If xCount > 0 Then
        MsgBox "number of " & CStr(xCount) & " text be bolded!", vbInformation, "Kutools for Excel"
        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

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


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!
Comments (10)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Worked perfectly fine for me. I track leases and the documents that need to be submitted by agents. I put "none" in the cells for the leases that have had all docs turned in. Bolding the words makes it easier to read!

Thanks again for the help!
Rated 5 out of 5
This comment was minimized by the moderator on the site
Awesome! Worked great!
This comment was minimized by the moderator on the site
I get the first pop up hit ok but then don't get the second pop up window to type in the word?
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
Hello, Sherry,
I can not see your screenshot, please upload it again.
Thank you!
This comment was minimized by the moderator on the site
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
There are no comments posted here yet
Load More
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations