Question
Excel VBA Please: Strategy: 1. Place a command button on this worksheet. Link the command button to your main sub. 2. Build a subroutine that
Excel VBA Please:
Strategy:
1. Place a command button on this worksheet. Link the command button to your main sub.
2. Build a subroutine that uses Solver to solve the current problem as it is.
3. In the worksheet Scenarios count the number of Scenarios to be run (Use Range and .end(xlToRight) to find the number of scenarios.
4. Use a For Next Loop to go through the different scenarios.
For each Scenario do the following:
5. Copy the plant capacities in the Scenarios worksheet to cells I13, I14, and I15, respectively, in the Model worksheet.
6. Copy the city demands in the Scenarios worksheet to cells C18, D18, E18, and F18, respectively, in the Model worksheet.
7. Solve the Problem by calling the Solver subroutine built in step 2.
8. Copy the results in the range C13:F15 in the Model worksheet to the Results worksheet (Note that the results for each scenario need 6 rows)
9. Copy the Total Cost in cell B20 in the Model worksheet to the Results worksheet (Note that the results for each scenario need 6 rows)
Go to the next Scenario.
You can use "Scenario " & i in the For Next loop to enumerate the scenarios.
Write code assuming that the number of plants is 3 and the number of cities is 4, but the number of scenarios is dynamic and can change.
Model Tab:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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