'格式问题,直接暴力解决
'其实[e12]也有问题
Option Explicit
Sub test()
Dim arr, i, j, t, dic, key, row
Set dic = CreateObject("scripting.dictionary")
row = Cells(Rows.Count, "e").End(xlUp).row
arr = Range("e6:e" & row)
For i = 1 To UBound(arr, 1)
If Len(arr(i, 1)) Then
t = Replace(arr(i, 1), Space(1), vbNullString)
t = Replace(t, ",", ",")
t = Replace(t, "'", vbNullString)
If InStr(t, ",") Then
t = Split(t, ",")
For j = 0 To UBound(t): dic(t(j)) = dic(t(j)) + 1: Next
Else
dic(t) = dic(t) + 1
End If
End If
Next
Cells(6, "e").Resize(row).Font.Color = vbBlack
For i = 6 To row
If Len(Cells(i, "e")) Then
For Each key In dic.keys
If InStr(Cells(i, "e"), key) Then
If dic(key) > 1 Then
Cells(i, "e").Characters(InStr(Cells(i, "e"), key), Len(key)).Font.Color = vbRed
End If
End If
Next
End If
Next
End Sub |