Excel VBA突出search

我试图在一个单元格中使用单词,然后转到另一个单元格,并在另一个单元格中find该单词。 棘手的部分是,第二张在许多地方都有这个词,我只希望单词突出显示为蓝色。

我已经尝试了以下,但循环不断传递蓝色突出显示的单词,并继续。 我究竟做错了什么?

Sub TryingIt() Dim r As Excel.Range Dim strName As String Dim strFirstFound As String strName = ActiveCell.Text Sheets("Waiting For").Select Range("A1").Select Cells.Find(What:=strName, After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate Set r = ActiveCell If r.Interior.color = vbBlue Then r.Offset(1, 0).Select Else: Do Cells.Find(What:=strName, After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate Set r = ActiveCell Loop While r.Interior.color <> vbBlue r.Offset(1, 0).Select End If End Sub 

答案如下:

你必须小心,要更具体的颜色。 就我而言,它是RGB(0,176,240) ,而不仅仅是vbBlue