Hi
I am trying to automate a solver procedure and have the following code:
The iteration procedure is working - moving the constraint from R15 to 16....etc as planned
However the procedure seems to be loosing the second constraint of Cell K27 =1
Any advice appreciated!
Thanks
Sub RunSolver()
'
Dim i As Integer
For i = 0 To 33
' RunSolver Macro
SolverReset
'
SolverOk SetCell:="$B$32", MaxMinVal:=2, ValueOf:=0, ByChange:="$K$20:$K$25", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverOk SetCell:="$B$32", MaxMinVal:=2, ValueOf:=0, ByChange:="$K$20:$K$25", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$B$29", Relation:=2, FormulaText:=Sheets("Sheet2").Range("$R$15").Offset(i, 0).Address
SolverOk SetCell:="$B$32", MaxMinVal:=2, ValueOf:=0, ByChange:="$K$20:$K$25", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$K$27", Relation:=2, FormulaText:="1"
SolverOk SetCell:="$B$32", MaxMinVal:=2, ValueOf:=0, ByChange:="$K$20:$K$25", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverOk SetCell:="$B$32", MaxMinVal:=2, ValueOf:=0, ByChange:="$K$20:$K$25", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
I am trying to automate a solver procedure and have the following code:
The iteration procedure is working - moving the constraint from R15 to 16....etc as planned
However the procedure seems to be loosing the second constraint of Cell K27 =1
Any advice appreciated!
Thanks
Sub RunSolver()
'
Dim i As Integer
For i = 0 To 33
' RunSolver Macro
SolverReset
'
SolverOk SetCell:="$B$32", MaxMinVal:=2, ValueOf:=0, ByChange:="$K$20:$K$25", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverOk SetCell:="$B$32", MaxMinVal:=2, ValueOf:=0, ByChange:="$K$20:$K$25", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$B$29", Relation:=2, FormulaText:=Sheets("Sheet2").Range("$R$15").Offset(i, 0).Address
SolverOk SetCell:="$B$32", MaxMinVal:=2, ValueOf:=0, ByChange:="$K$20:$K$25", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$K$27", Relation:=2, FormulaText:="1"
SolverOk SetCell:="$B$32", MaxMinVal:=2, ValueOf:=0, ByChange:="$K$20:$K$25", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverOk SetCell:="$B$32", MaxMinVal:=2, ValueOf:=0, ByChange:="$K$20:$K$25", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1