Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Making All Occurrences Bold.

Making All Occurrences Bold

by Allen Wyatt
(last updated April 24, 2017)

17

Tom rightly notes that in Word you can use Find and Replace to make all occurrences of a word bold. (Search for the word, replace it with the same word with bold formatting turned on.) He wonders how he can do the same thing in Excel.

The answer depends, in part, on the version of Excel you are using. If you are using Excel 2002 or a later version of Excel, the answer is easy—you do it virtually the same way that you do in Word. Follow these steps:

  1. Press Ctrl+H to display the Replace tab of the Find and Replace dialog box.
  2. Click the Options button to expand the dialog box. (See Figure 1.)
  3. Figure 1. The expanded Replace tab of the Find and Replace dialog box.

  4. In the Find What box, enter the word you want to make bold.
  5. Enter the same word in the Replace With box.
  6. Click the Format button to the right of the Replace With box. Excel displays the Replace Format dialog box.
  7. Click the Font tab. (See Figure 2.)
  8. Figure 2. The Font tab of the Replace Format dialog box.

  9. In the Font Style list, choose Bold.
  10. Click OK to close the Replace Font dialog box.
  11. Click Replace All to perform the replacements.

While this appears quite easy, you need to remember that these steps change the formatting of entire cells, not just words within a cell. Thus, if you were searching and replacing the word "brown," then any cell that contained the word "brown" would be made bold—the entire cell, not just the word.

If you are using an older version of Excel (Excel 97 or Excel 2000) or you want to only affect words within the cell, then these steps won't work. Instead you'll need to resort to a macro to do the bolding. Basically, you'll need a macro that looks through a worksheet and determines what can be changed. (You cannot make individual words or digits in formulas or numeric values bold; you can only make changes to the word-level formatting for text constants.)

Once the macro finds cells it can process, it needs to search through the cells for the desired word, and then make that text bold. The following macro implements this very strategy:

Sub FindAndBold()
    Dim sFind As String
    Dim rCell As Range
    Dim rng As Range
    Dim lCount As Long
    Dim iLen As Integer
    Dim iFind As Integer
    Dim iStart As Integer

    On Error Resume Next
    Set rng = ActiveSheet.UsedRange. _
      SpecialCells(xlCellTypeConstants, xlTextValues)
    On Error GoTo ErrHandler
    If rng Is Nothing Then
        MsgBox "There are no cells with text"
        GoTo ExitHandler
    End If

    sFind = InputBox( _
      Prompt:="What do you want to BOLD?", _
      Title:="Text to Bold")
    If sFind = "" Then
        MsgBox "No text was listed"
        GoTo ExitHandler
    End If

    iLen = Len(sFind)
    lCount = 0

    For Each rCell In rng
        With rCell
            iFind = InStr(.Value, sFind)
            Do While iFind > 0
                .Characters(iFind, iLen).Font.Bold = True
                lCount = lCount + 1
                iStart = iFind + iLen
                iFind = InStr(iStart, .Value, sFind)
            Loop
        End With
    Next

    If lCount = 0 Then
        MsgBox "There were no occurrences of" & _
          vbCrLf & "' " & sFind & " '" & _
          vbCrLf & "to bold."
    ElseIf lCount = 1 Then
        MsgBox "One occurrence of" & _
          vbCrLf & "' " & sFind & " '" & _
          vbCrLf & "was made bold."
    Else
        MsgBox lCount & " occurrences of" & _
          vbCrLf & "' " & sFind & " '" & _
          vbCrLf & "were made bold."
    End If

ExitHandler:
    Set rCell = Nothing
    Set rng = Nothing
    Exit Sub

ErrHandler:
    MsgBox Err.Description
    Resume ExitHandler
End Sub

The macro first sets the search range to those cells that contain text constants. It then prompts the user for a word that needs to be changed. Once entered, the macro then starts looking through all the cells in the range. Each cell is checked to see if it contains the target word. If so, then the .Bold property for those characters is set and the macro continues searching.

The macro also keeps track of how many changes were made, displaying the total changes at the end of its work.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2414) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Making All Occurrences Bold.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Counting Words

Do you need to know how many words are in a range of cells? Excel provides no intrinsic way to count the words, but you can ...

Discover More

Deleting Blank Columns

Import data from another program, and you could end up with a lot of blank columns in your data. Here's the quickest way to ...

Discover More

Permanent Watermarks in a Document

Need to add a graphic watermark to a document? It's not that hard to do, but making the watermark permanent can be a bit more ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (menu)

Searching for Leading Apostrophes

Take a look at the Formula bar when you select a cell that contains text, and you may see an apostrophe at the beginning of ...

Discover More

Searching for Line Breaks

If you need to find where line breaks are located in cells, there are a couple of ways you can proceed. Here's a quick ...

Discover More

Finding All Instances of a Value

Searching for information in an Excel worksheet generally goes very smoothly. There can be times, however, when the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 7 + 6?

2017-07-28 12:56:37

Becks

I'm sure that there's a way to modify this to loop through all worksheets in a workbook. Has anyone done this, if so what would it look like?


2017-04-24 09:55:50

Jamie Smith

Great Tip Allen! I use the find and replace feature often but was unaware that you could change the formatting in this way. Thanks for sharing!


2016-10-23 15:03:15

Vicki

Thank you!


2016-08-12 09:19:55

Mustafa

It works great. Thank you.


2016-03-07 01:36:19

hit

Your macro is really useful. can you help me with making all occurances Bold only in Comments of XLS.


2016-01-19 02:12:06

Peter

Persol hi,

try replace with this:


For Each rCell In rng
With rCell
iFind = InStr(1, .Value, sFind, vbTextCompare)
Do While iFind > 0
.Characters(iFind, iLen).Font.Bold = True
.Characters(iFind, iLen).Font.Color = 255
lCount = lCount + 1
iStart = iFind + iLen
iFind = InStr(iStart, .Value, sFind)


2016-01-14 10:18:13

Peter

Hi,

I have the same question as Persol;
What should I change in your code to allow me to target a range where I could list specific words and possible variations?

And:

How to add color to every bolded word?

Thank you in advance for your response
Kind regards
Piotr


2015-12-26 13:30:23

Persol

Hi Allen,
your macro works great. I was never aware it could be done. However, I have a small question or rather a request, what should I change in your code to allow me to target a range where I could list specific words and possible variations: as an example, my name

Persol
persol
PERSOL
PERSOl
pERSOL

would you kindly share your suggestions?
Persol


2015-07-12 08:14:09

Roger

The VBA code works great, but the Find & Replace bolds the entire cell in Excel 2010.


2015-04-17 00:04:57

Cath

Wonderful stuff, thank you.


2015-04-07 16:15:30

Kafi Johnson

This is an awesome tip!

I have one question... Can you program the macro to change the font color of the word, too?

Thank you!


2014-12-15 23:27:15

Bharath

Thanks for the macro. It worked great!


2014-07-25 12:16:19

Colleen

This worked perfectly, so you are my hero today. Thanks!


2014-06-27 03:11:24

Siva Krishna

I need a macro that will find & Replace the text in a cell without disturbing the format of othe contents of the cell?

Ex: Macros are very useful
is the text in the cell.The word Macros in the text is underlined and bold when you find and replace the word very useful then the entire sentence format is changing to bold and underline(i dont want this). Pls help me regarding this.


2014-05-02 06:08:48

KB

Can you also please let know on how we can search and display all the occurences of a word in a single spreasheet?


2014-04-16 07:44:20

Puneeth

Really it was very helpful to me....
Thanks a lot.


2013-01-08 08:38:51

ATorres

I was looking for a way to do this ...well done and thank you!


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.