Hi,
I am hoping someone can help with a problem I am having. I am trying to run a loop using solver for a problem that contains two sets of decision variables (spreadsheet columns AO:AY & BD:BN) but do not know how to modify the VBA code to make this happen. I was able to make the loop run successfully when I only had one set of variables, but the technique does not work when I add the second set..
The VBA code is below.
Any help would be greatly appreciated.
thank you.
Doug
Sub SolverLoop2Variable()
'
' SolverLoop2Variable Macro
'
' Dim r As Long
For r = 8 To 158
SolverReset
SolverOk SetCell:="$BQ$" & r, MaxMinVal:=1, ValueOf:=0, ByChange:= _
$AO$8:$AY$8,$BD$8:$BN$8", Engine:=2, EngineDesc:="Simplex LP"
SolverAdd CellRef:="$AO$" & r & ":$AY$", Relation:=5, FormulaText:="binary"
SolverAdd CellRef:="$AZ$" & r, Relation:=3, FormulaText:="$BB$8"
SolverAdd CellRef:="$BD$" & r & ":$BN$", Relation:=1, FormulaText:="$BF$4"
SolverAdd CellRef:="$BO$" & r, Relation:=2, FormulaText:="1"
SolverAdd CellRef:="$BR$" & r, Relation:=3, FormulaText:="$BS$8"
SolverAdd CellRef:="$BR$" & r, Relation:=1, FormulaText:="$BT$8"
SolverAdd CellRef:="$CG$" & r & ":$CQ$", Relation:=1, FormulaText:="$CJ$4"
SolverOk SetCell:="$BQ$8", MaxMinVal:=1, ValueOf:=0, ByChange:= _
$AO$8:$AY$8,$BD$8:$BN$8", Engine:=2, EngineDesc:="Simplex LP"
SolverOk SetCell:="$BQ$8", MaxMinVal:=1, ValueOf:=0, ByChange:= _
"$AO$8:$AY$8,$BD$8:$BN$8", Engine:=2, EngineDesc:="Simplex LP"
SolverSolve
End Sub
Bookmarks