Hi,
My name is Bo and I am using solver to solve my minimization problem in a loop in vba. I have set everything up and press F8 to go step by step. When I got the solversolve, it doesn't update the cell. And everytime after I ran the solversolve process, the formula calculation will be set to manual automatically and I need to change it back to automatic calculation everytime I went through solversolve. There are no errors popping up. It just doesn't have any effect on the spreadsheet. When I used the same setting and use the solver add-in by hand, it could update the cell. It just doesn't work in VBA. It will be appreciated if anyone could solve the problem. My code is :
Sheets("Temp").Select
Solverreset
SolverOptions MaxTime:=0, Iterations:=0, Precision:=0.000001, Convergence:= _
0.00001, StepThru:=False, Scaling:=True, AssumeNonNeg:=True, Derivatives:=2
SolverOptions PopulationSize:=0, RandomSeed:=0, MutationRate:=0.075, Multistart:= _
False, RequireBounds:=False, MaxSubproblems:=0, MaxIntegerSols:=0, IntTolerance _
:=1, SolveWithout:=True, MaxTimeNoImp:=30
SolverOk SetCell:="$AM$2", MaxMinVal:=2, ValueOf:=0, ByChange:="$R$17,$R$21", _
Engine:=1, EngineDesc:="GRG nonlinear"
SolverAdd CellRef:="$R$17", Relation:=1, FormulaText:="1"
SolverAdd CellRef:="$R$21", Relation:=1, FormulaText:="0.5"
SolverAdd CellRef:="$R$17", Relation:=3, FormulaText:="0.51"
SolverAdd CellRef:="$R$21", Relation:=3, FormulaText:="0"
solversolve userfinish:=True
Application.ScreenUpdating = True
Thank you!
Bookmarks