Solver Macro on Multiple Sheets

PeteC19

New Member
Joined
Nov 21, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I am trying to run a macro calling the Solver functions on multiple sheets. The Solver area works on a single sheet, but returns the error message on the 5 worksheets I am attempting to calculate. Any advice is most welcome. Also, running this macro switched calculation mode to Manual. I have set up a personal.xlab per instructions, and added the application. Calculation = xlAutomatic .

Sub Solverv2()
Dim xSh As Worksheet
Application.ScreenUpdating = True
For Each xSh In Worksheets
xSh.Select
Call RunCode
Next
Application.ScreenUpdating = True
End Sub
Sub RunCode()

Application.Calculation = xlAutomatic

SolverOptions Precision:=0.001
SolverOK SetCell:="$B$17", MaxMinVal:=3, ValueOf:="$B$7", ByChange:="$B$22"

SolverSolve UserFinish:=False

End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I fixed the issue of the macro switching to manual. There was a link to a manual workbook, that I deleted and fixed that issue.
Also improved the macro with the addition of Engine:=1 in the SolverOK line.
 
Upvote 0

Forum statistics

Threads
1,223,876
Messages
6,175,129
Members
452,614
Latest member
MRSWIN2709

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top