Find Some Values And Make Them Bold in Excel

In this post we will see how to find some values in excel and make them bold, the task is to find some values in excel sheet and make all the occurrence of that string in excel as Bold.

Below is the data which shows list of countries and we want to make all African countries from that list as Bold, we have to specify the values to excel and excel will find all the occurrence of that value in the worksheet and make all of them bold.

Excel showing values that needs to be found and converted to bold

Step 1

Open VB editor from Developer tab in excel as shown in the figure.

Open developer tab to write VBA find values and make them bold

Step 2

Insert a module in which we will write a VBA code to find the values and make them bold in excel sheet.

Insert a module in the VB editor

Step 3

Now double click the newly created module to open that and paste the below code in the module.

Sub Make_Bold()

Dim rCell As Range, sToFind As String, iSeek As Long

Dim Text(1 To 4) As String

Dim i As Integer

 Text(1) = “Zaire”

Text(2) = “Nigeria”

Text(3) = “Kenya”

Text(4) = “Zambia”

 For Each rCell In Range(“A1:A10”)

    For i = LBound(Text) To UBound(Text)

            sToFind = Text(i)

            iSeek = InStr(1, rCell.Value, sToFind)

        Do While iSeek > 0

            rCell.Characters(iSeek, Len(sToFind)).Font.Bold = True

            iSeek = InStr(iSeek + 1, rCell.Value, sToFind)


    Next i

Next rCell

 End Sub

VBA code to specify a list of values that we want to convert to bold

We are specifying some values in this code and telling the excel to find all the specified values in the sheet and make all of tem bold, as you can see we have specified the names of some african countries in code and want excel to find them and make them bold.

Now run the code by pressing F5 or by pressing play button the editor.

Below is the result that we get after running the code, as you can see in the result all the specified names have been converted to bold formatting.

Result showing all the values are found and converted to bold

Hope this helped.

Share The Knowledge

Random Posts