I'm not sure if this fix all the problems but change your function line into the following:
Range("C2").Formula = "=((2 * $H$2)/ $H$1) * SQRT(($F$1 * A2) / PI())"
(SQRT
instead of SQR
)
Additional tip, sometimes it could be better to name correctly object properties, in your situation I would suggest to use .Formula
when inserting function into range, like:
Range("C2").Formula = "=((2 * $H$2)/ $H$1) * SQRT(($F$1 * A2) / PI())"
Range("D2").Formula = "=((ABS(B2-C2))^2)"
Range("D" & Counter + 2).Formula = "=Sum(D2, D" & Counter + 1 & ")"
I know it's working usually what you have but my suggestion is a good habit which I stick to :)