Option Explicit
Sub test2()
Dim r As Range
Dim v
Dim i As Long
ActiveSheet.Copy
Set r = Range("k1", Range("k1").End(xlDown)).Resize(, 18)
v = r.Value
For i = 1 To UBound(v)
If v(i, 5) = "Sell" Then v(i, 18) = v(i, 18) * -1
Next
r.Value = v
r.Columns(18).FormatConditions.Add( _
Type:=xlExpression, _
Formula1:="=AND(R[0]C[0]=0,ISBLANK(R[0]C[-13]))") _
.Interior.Color = vbGreen
r.Rows(1).Insert xlDown
Set r = Range("k1").Resize(i, 18)
Application.DisplayAlerts = False
r.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(18), SummaryBelowData:=True
Application.DisplayAlerts = True
r.Rows(1).Delete xlUp
End Sub