Question
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
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 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.
For example, if A is 2 and B is 11, then the sum of even numbers (2+4+6+8+10) would be 30, the sum of odd numbers (3+5+7+9+11) would be 35, and the third sum (5+10+15+20) would be 50.
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.
Use the Option Explicit statement for this macro. Highlight and label the cells where the user must input data and the cells where data will be output by the macro. Assume the user will input all necessary values on the worksheet before clicking the run button.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started