I am trying to sum squares with VBA.
I get an overflow error when i = 182 and sum = 1992991.
I hoped that declaring sum as long would take care of big numbers.
Sub NaturalNumbers()
Dim i As Integer
Dim sum As Long
sum = 0
For i = 1 To 1000
sum = sum + (i * i)
Range("A" & i) = i
Range("D" & i) = sum
Next
MsgBox "Sum is " & sum
End Sub