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.
Written by Allen Wyatt (last updated April 21, 2018)
This tip applies to Excel 97, 2000, 2002, and 2003
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:
Figure 1. The expanded Replace tab of the Find and Replace dialog box.
Figure 2. The Font tab of the Replace Format dialog box.
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.
Note:
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.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
Need to add some characters to the beginning of the contents in a range of cells? It's not as easy as you might hope, but ...
Discover MoreTake a look at the Formula bar when you select a cell that contains text, and you may see an apostrophe at the beginning ...
Discover MoreWildcard characters can be used within the Find and Replace tool, but what if you want to actually search for those ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2022-12-07 11:59:29
Samantha
Is there any way to add an exception? I have this running to bold any "&" but i need "T & S Masks" to not have the "&" bold
2020-05-11 02:38:23
Maurice Linker
How do I bold a word in excel for an iPad with iOS
2019-10-25 09:30:07
Krishna
Hello Allen,
This method changes entire cell format to 'Bold'. Is there a way to change to make only particular text in a cell to 'Bold' at multiple locations. For example, I want to make 'The' to Bold where ever it appears. Is it possible in Excel?
2019-10-15 20:33:19
Kit
Hi Allen, thanks for the tutorial. Is there a way to just bold the text but not the entire cell?
2019-03-19 13:31:12
me
love the script but somehow it my XLS is corrupted after I run it..
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments