Sub Rang()
With Range("F3:F" & Range("A" & Rows.Count).End(xlUp).Row)
.FormulaR1C1 = _
"=SUMPRODUCT((R3C[-5]:R650000C[-5]=RC[-5])*(R3C[-4]:R650000C[-4]=RC[-4])*(R3C[-2]:R650000C[-2]=RC[-2])*(RC[-1]>R3C[-1]:R650000C[-1]))+SUMPRODUCT((R3C[-4]:RC[-4]=RC[-4])*(R3C[-2]:RC[-2]=RC[-2])*(R3C[-1]:RC[-1]=RC[-1]))"
.Value = .Value
End With
End Sub