录制宏是个好办法,下面做了下,供参考,我试了也可以,需要先在vba编辑器里把solver的引用选了
Sub 每个工作表规划求解()
Dim sh As Worksheet, wb As Workbook
Set wb = ThisWorkbook
For Each sh In wb.Sheets
sh.Activate
SolverOk SetCell:="$F$17", MaxMinVal:=3, ValueOf:=0, ByChange:="$C$7", Engine:= _
1, EngineDesc:="GRG Nonlinear"
SolverOptions MaxTime:=0, Iterations:=0, Precision:=0.0000001, Convergence:= _
0.0000001, StepThru:=False, Scaling:=True, AssumeNonNeg:=True, Derivatives:=1
SolverOptions PopulationSize:=100, RandomSeed:=0, MutationRate:=0.075, Multistart _
:=False, RequireBounds:=True, MaxSubproblems:=0, MaxIntegerSols:=0, _
IntTolerance:=1, SolveWithout:=False, MaxTimeNoImp:=30
SolverOk SetCell:="$F$17", MaxMinVal:=3, ValueOf:=0, ByChange:="$C$7", Engine:= _
1, EngineDesc:="GRG Nonlinear"
SolverOk SetCell:="$F$17", MaxMinVal:=3, ValueOf:=0, ByChange:="$C$7", Engine:= _
1, EngineDesc:="GRG Nonlinear"
SolverSolve
Next
End Sub
|