Private Sub Worksheet_Change(ByVal Target As Range) On Error Resume Next Dim r As Integer If Not Intersect(Target.Cells(1, 1), Union(Range("D18:D39"), Range("F18:F39"), Range("O18:O39"))) Is Nothing Then r = Target.Row If Cells(r, "D").Value <> "" Then Cells(r, "C").Value = r - 17 Cells(r, "G").Value = Val(IIf(Cells(r, "O") <> "", Cells(r, "O"), Cells(r, "N"))) Cells(r, "H").Value = Val(Cells(r, "F")) * Val(Cells(r, "G")) Cells(r, "N").Value = WorksheetFunction.VLookup(Cells(r, "D"), [prices], 3, 0) Cells(r, "P").Value = WorksheetFunction.VLookup(Cells(r, "D"), [prices], 4, 0) Cells(r, "L").Value = WorksheetFunction.VLookup(Cells(r, "D"), [prices], 10, 0) Cells(r, "Q").Value = (Val(Cells(r, "G")) - Val(Cells(r, "P"))) * Val(Cells(r, "F")) Else Union(Cells(r, "C"), Cells(r, "H"), Cells(r, "N"), Cells(r, "P"), Cells(r, "Q")).ClearContents End If End If On Error GoTo 0 End Sub =IF(E10="";"";VLOOKUP(E10;address;3;0)) =SUMPRODUCT((الوكلاء!$E$5:$E$2002<=$E$8)*(الوكلاء!$D$5:$D$2002=E10)*(الوكلاء!$H$5:$H$2002))