Thread: VBA Excel
View Single Post
Old 10-17-2010, 12:54 AM   #22
iggyntangs
Scoring Winger
 
iggyntangs's Avatar
 
Join Date: Oct 2010
Exp:
Default

I think we're in the same class, but anyway I got it right here's what I had for anyone that may have been curious:

Sub SUMMATION()

Dim Neg_Int As Integer, Int_Err As Boolean, Sum As Double, i As Integer

Sum = 0
Int_Err = False

Do Until Int_Err

Neg_Int = InputBox("Please enter a negative even integer:")

If Neg_Int Mod 2 = 0 And Neg_Int < 0 Then
Int_Err = True
Else
MsgBox "You have entered an incorrect number." _
& " Please enter an even integer less than zero."
End If

Loop

For i = Neg_Int To 121

If i Mod 2 = 0 Then
Sum = Sum + i
End If

Next
MsgBox "The formula has summed all the even integers from your negative integer of " _
& Neg_Int _
& " to 121." _
& vbNewLine & vbNewLine & "Answer: " & Sum

End Sub
iggyntangs is offline   Reply With Quote