Try:
Sub InsertRows()
Application.ScreenUpdating = False
Dim v As Variant, i As Long, fRow As Long, lRow As Long
With ActiveSheet
.Range("B1").CurrentRegion.AutoFilter 2, "YOGLP"
.AutoFilter.Range.Offset(1).EntireRow.Delete
.Range("B1").AutoFilter
End With
v = Range("B2", Range("B" & Rows.Count).End(xlUp)).Resize(, 6).Value
For i = UBound(v) - 1 To LBound(v) Step -1
If v(i, 1) <> v(i + 1, 1) Then
Cells(i + 2, 1).EntireRow.Insert
ElseIf v(i, 6) <> v(i + 1, 6) Then
Cells(i + 2, 1).EntireRow.Insert
End If
Next i
With Range("B2", Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeConstants)
For i = 1 To .Areas.Count
fRow = .Areas(i).Cells(1).Row
lRow = .Areas(i).Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
With Range("F" & lRow + 1)
.Formula = "=Sum(F" & fRow & ":F" & lRow & ")"
.Font.Bold = True
End With
Next i
End With
Application.ScreenUpdating = True
End Sub
Bookmarks