السلام عليكم
جرب الكود التالي:
Option Explicit
Sub kh_Color()
Dim Obj As Object
Dim cel As Range
Dim MyColor
Dim txt As String
Dim LR As Long, R As Long
'''''''''''''''''''''''''''''
Set Obj = CreateObject("Scripting.Dictionary")
'''''''''''''''''''''''''''''
MyColor = 2287936
'''''''''''''''''''''''''''''
LR = Cells(Rows.Count, "B").End(xlUp).Row
Range("B5:K" & LR).Interior.Color = xlNone
For R = 5 To LR
txt = Trim(Cells(R, "K"))
If Len(txt) Then
If Obj.Exists(txt) Then
Range(Cells(R, "B"), Cells(R, "K")).Interior.Color = Obj(txt)
Else
Obj.Add txt, MyColor
Range(Cells(R, "B"), Cells(R, "K")).Interior.Color = MyColor
MyColor = MyColor + 500000
End If
End If
Next
Set Obj = Nothing
End Sub
شاهد المرفق 2003
تلوين المكرر بلون محتلف.rar