对不起,我现在没有时间完成这个,但是 w像这样的帮助第一列中的每个单元格可能都有一个循环?
编辑:现在完成,第二次编辑更新到 B5 和 Z5,编辑 3 个带有列引用的固定错误,并更新为使用变量来分配要查看的列。
Sub colortext()
start_row = 5
key_col = 2
linked_col = 26
i = start_row 'start on row one
Do While Not IsEmpty(Cells(i, key_col)) 'Do until empty cell
o = start_row 'start with row one for second column
Do While Not IsEmpty(Cells(o, linked_col)) 'Do until empty cell
If Not InStr(1, Cells(o, linked_col), Cells(i, key_col)) = 0 Then 'if cell contents found in cell
With Cells(o, linked_col).Characters(Start:=InStr(1, Cells(o, linked_col), Cells(i, key_col)), Length:=Len(Cells(i, key_col))).Font
.Color = Cells(i, key_col).Font.Color 'change color of this part of the cell
End With
End If
o = o + 1 'increment the cell in second column
Loop
i = i + 1 'increment the cell in the first column
Loop
End Sub
或者可能
像这样的东西?
Excel VBA:更改单元格范围内特定字符的字体颜色