gpt-3.5-turbo-0125· OpenAI
WildChat-4.8M (AI2)
Write a vba code to calculate add function from 1 to 100
- User
Write a vba code to calculate add function from 1 to 100
- Assistant
Here is a VBA code to calculate the sum of numbers from 1 to 100:
Sub CalculateSum() Dim sum As Integer Dim i As Integer sum = 0 For i = 1 To 100 sum = sum + i Next i MsgBox "The sum of numbers from 1 to 100 is: " & sum End SubYou can run this code in the VBA editor in Excel by pressing Alt + F11, inserting a new module, and pasting the code into the module. Then you can run the
CalculateSumsubroutine to see the sum of numbers from 1 to 100 displayed in a message box.