Dựa theo VBA của bài #4 có thể phát triển ra kết quả như này hy vọng đúng với ý tưởng của bạn:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range, rng As Range
Dim v As String
Dim chkCell As Range
Dim isDup As Boolean
Dim Rws As Long, Col As Long
On Error GoTo ExitHandler
Application.EnableEvents = False
Rws = Me.UsedRange.Rows.Count
Col = Me.UsedRange.Columns.Count
Set rng = Me.Range("J4").Resize(Rws, Col)
If Not Intersect(Target, rng) Is Nothing Then
For Each c In Target
If c.Value <> "" Then
v = Trim(CStr(c.Value))
If Len(v) <> 5 Then
c.Interior.Color = vbYellow
Else
isDup = False
For Each chkCell In Me.Range("J4", c)
If chkCell.Address = c.Address Then Exit For
If Trim(CStr(chkCell.Value)) = v Then
isDup = True
Exit For
End If
Next chkCell
If isDup Then
c.Interior.Color = vbRed
Else
c.Interior.ColorIndex = xlNone
End If
End If
Else
c.Interior.ColorIndex = xlNone
End If
Next c
End If
ExitHandler:
Application.EnableEvents = True
End Sub