在单元格中更改为粗体重复的文本

我正在尝试编写一些代码,如果它包含我正在查找的单词,并将其设置为粗体,将会查找Excel单元格中的代码。 到目前为止,我已经写了下面的代码

With Worksheets("Label Print").Cells(i, J) .Characters(Start:=InStr(.Value, “Name”), Length:=Len(“Name”)).Font.Bold = True End With 

问题是,如果“名称”在单元格中出现两次(或多次),则只会突出显示其第一次出现。

先谢谢你

这是一个函数,它将单元格检查并search单词,并加粗该单词的所有情况:

 Public Sub BoldWord(rngCell As Range, sWord As String) Dim iPlace As Integer iPlace = InStr(1, rngCell.Value, sWord, vbTextCompare) Do While iPlace > 0 rngCell.Characters(Start:=iPlace, Length:=Len(sWord)).Font.Bold = True iPlace = InStr(iPlace + 1, rngCell.Value, sWord, vbTextCompare) Loop End Sub 

注1:rngCell必须是单个单元格。

注2:search不区分大小写…必要时更改vbTextCompare。