اضفنا عمود يمين جدول البيانات
جعلناه كمعيار للترحيل ( يمكنك اخفاءه )
شاهد الكود
Sub KH_START()
Dim cel As Range
Dim LR As Integer, M As Integer, C As Integer
Dim iTest As String
With Main
iTest = .[H7].Value2 & "-" & .[B13].Value2
End With
With Products
LR = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
M = Val(CStr(Application.Match(iTest, .Range("A2:A" & LR), 0)))
If M Then
M = M + 1
For C = 1 To 6
.Cells(M, C + 4).Value = Val(.Cells(M, C + 4)) + Val(Main.Range("C13").Cells(1, C))
Next
Else
.Cells(LR, "A").Value = iTest
.Cells(LR, "B").Value = Main.[B13]
.Cells(LR, "C").Value = Main.[H7]
.Cells(LR, "D").Value = Main.[C7]
.Cells(LR, "E").Resize(1, 6).Value = Main.Range("C13:H13").Value
End If
End With
End Sub
المرفق 2010
TA.rar