如何比对两个单元格内相同文字?

比如前面单元格内内容为“我们是无限能量的男人” 后面单元格内是“有限能量” ,前后两个单元格内文字重复的只有“限能量”这三个字,如何将两个单元格内的这三个字标上高亮颜色?!!
山东省
浏览 144
收藏
3
分享
3 +1
4
+1
全部评论 4
 
Sub 大于3标红() Dim rng As Range, cell As Range Dim str1 As String, str2 As String Dim i As Long, j As Long, lenCommon As Long For Each rng In Selection.Columns If rng.Column < Selection.Columns(Selection.Columns.Count).Column Then For Each cell In rng.Cells If cell.Value <> "" And cell.Offset(0, 1).Value <> "" Then str1 = cell.Value: str2 = cell.Offset(0, 1).Value For i = 1 To Len(str1) - 2
· 安徽省
1
回复
For j = 1 To Len(str2) - 2 If Mid(str1, i, 3) = Mid(str2, j, 3) Then lenCommon = 3 cell.Characters(i, lenCommon).Font.Color = RGB(255, 0, 0) cell.Offset(0, 1).Characters(j, lenCommon).Font.Color = RGB(255, 0, 0) End If Next j Next i
· 安徽省
1
回复
 
编程实现。
· 河南省
回复