How would I write a VBA sub procedure that adds all numbers from the first given number to the last number? so far I have gotten the inputboxs to store data but im not sure how to do the rest.

Sub number()

A = InputBox("Start Number.", "Data Entry: 1")

B = InputBox("End Number.", "Data Entry: 2")

End SubAny help would be greatly appreciated, Thank You.

Is this a homework assignment? BTW...before you post any more code in this forum, please click on the following line and read the instructions found via that link.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Indeed it is.

Sorry I didnt realize there was a system for posting VBA code, I will follow up appropriately.Sub number() Dim A As Integer Dim B As Integer A = InputBox("Start Number.", "Data Entry: 1") B = InputBox("End Number.", "Data Entry: 2") End Sub

I have figured out the coding for this question

it is as follows for anyone interestedSub number() Dim A As Integer Dim B As Integer Dim C As Integer A = InputBox("Start Number.") B = InputBox("End Number.") C = 0 For d = A To B C = C + d Next d End Sub

Ask Your Question

Weekly Poll

How long do you think until flying cars or taxis are common?

Discuss in The Lounge

Poll History