جرب هذا الكود
بداية قم بإزالة الدمج في الورقة 2 وكذلك امسح البيانات فيها
ثم فعل الكود
Sub Abu_Ahmed()
Set MySh = Sheets("ورقة2")
For i = 1 To 30
If i = 1 Then
MySh.Range("A" & MySh.[A10000].End(xlUp).Row) = [D4]
MySh.Range("A" & MySh.[A10000].End(xlUp).Row & ":" & "B" & MySh.[A10000].End(xlUp).Row).Merge
End If
If i = (Val([E4]) + 1) Then
MySh.Range("A" & MySh.[A10000].End(xlUp).Row + 3) = [D5]
MySh.Range("A" & MySh.[A10000].End(xlUp).Row & ":" & "B" & MySh.[A10000].End(xlUp).Row).Merge
End If
If i = (Val([E4]) + Val([E5]) + 1) Then
MySh.Range("A" & MySh.[A10000].End(xlUp).Row + 3) = [D6]
MySh.Range("A" & MySh.[A10000].End(xlUp).Row & ":" & "B" & MySh.[A10000].End(xlUp).Row).Merge
End If
MySh.Range("A" & MySh.[A10000].End(xlUp).Row + 1) = Cells(i + 1, 1)
Next
End Sub