Hi,

try this:
Sub Test()
    Dim i As Long, iSrt As Long
    With Worksheets("2013")
        iSrt = 2
        For i = iSrt To .Cells(.Rows.Count, 1).End(xlUp).Row
            If .Cells(i, 5).Value <> .Cells(i + 1, 5).Value Then
                .Cells(i, 15).Formula = "=SUM(M" & iSrt & ":M" & i & ")"
                .Cells(i, 16).Formula = "=IF(G" & i & "=0,"""",IF((O" & i & "/G" & i & ">=90%),"""",O3-(G" & i & "*0.9)))"
                .Cells(i, 17).Formula = "=IF(G" & i & "=0,"""",IF((O" & i & "/G" & i & ">100%),O" & i & "-G" & i & ",""""))"
                .Cells(i, 18).Formula = "=IF(COUNT(M2:N2)=0,"""",COUNT(M" & iSrt & ":M" & i & "))"
                iSrt = i + 1
            End If
        Next i
    End With
End Sub
not sure about the formula in column R, where does the range for the 1st count come from?