تفضل
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [D7:D1000,F7:F1000]) Is Nothing Then
Cells(Target.Row, 8).FormulaR1C1 = "=IF(RC[-2]="""","""",VLOOKUP(RC[-2],prices,2,0))"
Cells(Target.Row, 9).FormulaR1C1 = "=IF(RC[-3]="""","""",RC[-2]*RC[-1])"
Cells(Target.Row, 10).FormulaR1C1 = "=IF(COUNTIF(RC[-7]:R5C[-7],RC[-7])=1,SUMIF(C[-7],RC[-7],C[-1]),"""")"
Cells(Target.Row, 11).FormulaR1C1 = "=IF(RC[-5]="""","""",VLOOKUP(RC[-5],prices,3,0))"
Cells(Target.Row, 12).FormulaR1C1 = "=IF(RC[-6]="""","""",RC[-5]*(RC[-4]-RC[-1]))"
For i = 8 To 12
Cells(Target.Row, i).Value = Cells(Target.Row, i)
Next
End If
End Sub