Im very new on VBA and i was hoping if anyone could help me out on this:
I have to write a subordinate that requests the user to enter a negative even integer using an input box. The subroutine also needs to sum all the even integers between 99 and the inputted number and display the result in a message box. It must also must include error checking that validates the initial inputted number as negative, as even, and as an integer.
This is what i came up with but it doesn't seem to be working proper:
Option Explicit
Sub NegativeEvenIneteger()
Dim Sum As Double
Dim NumberInput As Integer
Dim x As Double
NumberInput = InputBox("Please Enter a Negative Even Integer")
If NumberInput >= 0 Then MsgBox ("ERROR, Input number must be Negative")
If NumberInput Mod 2 = 0 Then MsgBox ("ERROR, Input number must be Even")
Sum = 0
For x = NumberInput + 1 To 0 Step 2
Sum = Sum + x
Next
MsgBox ("This equals " & Sum) & vbCrLf & _
("based on the inputted number of ") & NumberInput
End Sub
Please let me know what you guys think.