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

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
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,215,073
Messages
6,122,976
Members
449,095
Latest member
Mr Hughes

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