أخى الفاضل
جرب هذا الكود وأخبرنى بالنتيجة
Sub ragab()
Application.ScreenUpdating = False
Dim LR1 As Integer, LR2 As Integer, LC As Integer
Dim cl As Range, cel As Range, i As Integer
'====================================================================
LR1 = Sheets("الصادر").Cells(Rows.Count, "Q").End(xlUp).Row
LR2 = Sheets("ماده-وكيل").Cells(Rows.Count, "B").End(xlUp).Row
LC = [iv3].End(xlToLeft).Column
'====================================================================
Set Rng1 = Range(Cells(3, 4), Cells(3, LC))
Set Rng2 = Sheets("الصادر").Range("Q5:Q" & LR1)
'====================================================================
Range("D5:P" & LR2).ClearContents
For i = 5 To LR2
For Each cl In Rng1
For Each cel In Rng2
If Cells(i, 2) = cel And cl = cel.Offset(0, 4) Then
Cells(i, cl.Column) = Cells(i, cl.Column) + cel.Offset(0, 1)
End If
Next
Next
Next
Set Rng1 = Nothing
Set Rng2 = Nothing
Application.ScreenUpdating = True
End Sub
تعديل كود.rar