اذهب الي المحتوي
أوفيسنا

الردود الموصى بها

  • تمت الإجابة
قام بنشر (معدل)

السلام عليكم

جرب الكود 

Sub تلوين_المكرر()
    Dim ws As Worksheet, rng As Range, cell As Range
    Dim dict As Object, lastRow As Long
    Dim r As Long, c As Long, key As String
    
    Set ws = ActiveSheet
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    If lastRow < 5 Then lastRow = 5
    
    Set rng = ws.Range("A5:J" & lastRow)
    rng.Interior.ColorIndex = xlNone
    
    Application.ScreenUpdating = False
    
    For r = 5 To lastRow
        For c = 1 To 10
            Set cell = ws.Cells(r, c)
            If Not IsError(cell.Value) And Len(cell.Value) > 0 Then
                key = Trim(cell.Value)
                
                Set dict = CreateObject("Scripting.Dictionary")
                For Each c2 In ws.Range(ws.Cells(r, 1), ws.Cells(r, 10))
                    If c2.Value = key Then dict(key) = dict(key) + 1
                Next
                If dict(key) > 1 Then cell.Interior.Color = vbRed: GoTo NextCell
                
                ' التحقق عموديًا
                dict.RemoveAll
                For Each r2 In ws.Range(ws.Cells(5, c), ws.Cells(lastRow, c))
                    If r2.Value = key Then dict(key) = dict(key) + 1
                Next
                If dict(key) > 1 Then cell.Interior.Color = vbRed
            End If
NextCell:
        Next c
    Next r
    
    Application.ScreenUpdating = True
End Sub

 

تم تعديل بواسطه عبدالله بشير عبدالله
  • Thanks 1

انشئ حساب جديد او قم بتسجيل دخولك لتتمكن من اضافه تعليق جديد

يجب ان تكون عضوا لدينا لتتمكن من التعليق

انشئ حساب جديد

سجل حسابك الجديد لدينا في الموقع بمنتهي السهوله .

سجل حساب جديد

تسجيل دخول

هل تمتلك حساب بالفعل ؟ سجل دخولك من هنا.

سجل دخولك الان
  • تصفح هذا الموضوع مؤخراً   1 عضو متواجد الان

×
×
  • اضف...

Important Information