try changing all instances of ActiveCell.Row to c.Row.
Or forget the row references and use:
If c = "row1" Then c.Offset(0, -2).FormulaR1C1 = "=SUMIFS(C8,C12,C13,C18,RC17)-SUMIFS(C9,C12,C13,C18,RC17)"
and since you're referring to entire columns in the formula it might be resource hungry so you might try the likes of:
If c = "row1" Then c.Offset(0, -2).FormulaR1C1 = "=SUMIFS(R2C8:R" & Rws & "C8,R2C12:R" & Rws & "C12,R2C13:R" & Rws & "C13,R2C18:R" & Rws & "C18,RC17)-SUMIFS(R2C9:R" & Rws & "C9,R2C12:R" & Rws & "C12,R2C13:R" & Rws & "C13,R2C18:R" & Rws & "C18,RC17)"
If you're looking for some extra speed then you can try the likes of:
Sub insertsumifsa2()
Dim Rws As Long, Rng As Range, c As Range, FormulaRng As Range
Rws = Cells(Rows.Count, "p").End(xlUp).Row
Set Rng = Range(Cells(2, "p"), Cells(Rws, "p"))
For Each c In Rng.Cells
If c = "row1" Then
If FormulaRng Is Nothing Then Set FormulaRng = c.Offset(, -2) Else Set FormulaRng = Union(FormulaRng, c.Offset(, -2))
End If
Next c
If Not FormulaRng Is Nothing Then FormulaRng.FormulaR1C1 = "=SUMIFS(R2C8:R" & Rws & "C8,R2C12:R" & Rws & "C12,R2C13:R" & Rws & "C13,R2C18:R" & Rws & "C18,RC17)-SUMIFS(R2C9:R" & Rws & "C9,R2C12:R" & Rws & "C12,R2C13:R" & Rws & "C13,R2C18:R" & Rws & "C18,RC17)"
End Sub