Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is for VBA The user (me) will input two positive integers into cells C3 and

ID: 3791849 • Letter: T

Question

This is for VBA

The user (me) will input two positive integers into cells C3 and C4 on Sheet1.

Create a run button on Sheet1 that executes a macro named problem1. This macro performs the following tasks:

Obtain the two integers A and B from cells C3 and C4 on Sheet1, then check is A is less than B. If A is greater than B, tell the user that A needs to be smaller than B via a message box then end the program.

Use a For loop to determine the sum of all even integers from A to B.

Use a For loop to determine the sum of all odd integers from A to B.

Use a For loop to determine the sum of all integers that are evenly divisible by 5 from A to 2*B

Output the smallest of the three sums to cell E6, the middle sum in cell E7, and the largest of the three sums to cell E8.

You may solve this problem by using as many For loops as you like, but do not use Do loops.

Explanation / Answer


1&2 Dim Evens As Integer = 0 Dim Odds As Integer = 0 For i = AnyNumber to AnyOtherNumber If i Mod 2 = 0 Then Evens += i Else Odds += i End If


3 Dim var As Integer
Dim startVal As Integer
Dim endVal As Integer
Dim sum As Integer
startVal = 0
endVal = 15
sum = 0
For var = startVal To endVal
IF var Mod 5 Then
Sum+=var
Debug.Print f
   Next var


  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote