=SUM(ROW(INDIRECT("1:"&A1))), which is an array formula and must be confirmed with CTRL+SHIFT+ENTER (doing so will result in Excel putting { }'s around your formula in the formula bar).
Of course, this limits your input to a maximum of 65536. If that doesn't suit your needs, you'll likely need to use VBA.
Function SumOneToN(LNumber As Long) As Double
Dim n As Integer, temp As Double
n = 1
If LNumber < 0 Then
n = -1
LNumber = Abs(LNumber)
End If
If LNumber <= 1 Then SumOneToN = LNumber * n: Exit Function
Do While LNumber > 0
temp = temp + LNumber
LNumber = LNumber - 1
Loop
SumOneToN = temp * n
End Function
Which will also work with negative numbers if that interests you.
We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel
Which adblocker are you using?
Disable AdBlock
Follow these easy steps to disable AdBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the icon in the browser’s toolbar. 2)Click on the "Pause on this site" option.
Go back
Disable AdBlock Plus
Follow these easy steps to disable AdBlock Plus
1)Click on the icon in the browser’s toolbar. 2)Click on the toggle to disable it for "mrexcel.com".
Go back
Disable uBlock Origin
Follow these easy steps to disable uBlock Origin
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.
Go back
Disable uBlock
Follow these easy steps to disable uBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.