Hi
Assumed your data's start A1 & row1 is headers
Try
Sub test()
Dim a, w
Dim i&, ii&, c&
Application.ScreenUpdating = False
With CreateObject("scripting.dictionary")
.comparemode = 1
For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If Not .exists(Cells(i, 1).Value) Then
.Add (Cells(i, 1).Value), Array(Cells(i, 1).Address, 1)
Else
w = .Item(Cells(i, 1).Value): w(1) = w(1) + 1: .Item(Cells(i, 1).Value) = w
End If
Next
w = .Items: ii = .Count - 1
End With
For i = ii To 1 Step -1
With ActiveSheet.Range(w(i)(0)).Offset(w(i)(1))
.EntireRow.Insert
.Offset(-1, 4).Resize(, 5).FormulaR1C1 = "=SUM(R[-" & w(i)(1) & "]C:R[-1]C)"
.Offset(-1, 9).FormulaR1C1 = "=RC[-1]/RC[-5]"
End With
Next
Application.ScreenUpdating = True
End Sub
Bookmarks