VBA sub procedure

November 13, 2011 at 17:01:44
Specs: Windows 7
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 Sub

Any help would be greatly appreciated, Thank You.


See More: VBA sub procedure

Report •


#1
November 13, 2011 at 20:30:33
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.


Report •

#2
November 13, 2011 at 20:41:58
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


Report •

#3
November 13, 2011 at 22:12:14
I have figured out the coding for this question
it is as follows for anyone interested

Sub 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


Report •

Related Solutions


Ask Question