Here is a pieace of code I paste together its not everything you ask but it might get you started.
Sub InsertRow()
Dim i As Long
For i = Cells(2 ^ 16, 9).End(xlUp).Row To 3 Step -1
If Cells(i, 9).Value <> Cells(i - 1, 9).Value Then
Rows(i).Insert
Else
End If
Next i
For Each NumRange In Columns("H").SpecialCells(xlConstants, xlNumbers).Areas
SumAddr = NumRange.Address(False, False)
NumRange.Offset(NumRange.Count, 0).Resize(1, 1).Formula = "=DOLLAR(SUM(" & SumAddr & "))"
c = NumRange.Count
Next NumRange
NoData:
Db = """"
maxrow = Range("H65536").End(xlUp).Row
MyFormula = "=DOLLAR(SUMIF(I2:I" & maxrow & "," & """=""" & ",H2:H" & maxrow & "))"
Range("H" & maxrow + 1) = MyFormula
End Sub