+ Reply to Thread
Results 1 to 4 of 4

Solver loop with 2 sets of decision variables

  1. #1
    Registered User
    Join Date
    08-12-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    4

    Solver loop with 2 sets of decision variables

    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

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Solver loop with 2 sets of decision variables

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    08-12-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Solver loop with 2 sets of decision variables

    Thank you!

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Solver loop with 2 sets of decision variables

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. IF formula for sets of variables
    By RMaestri in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-28-2009, 01:32 PM
  2. REPLACE 2 different sets of variables?
    By Bwangster12 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-14-2008, 01:17 PM
  3. Counting function with 2 sets of variables
    By jalum in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-09-2007, 03:38 PM
  4. Set solver constraints so variables are either 1 OR 0.
    By Gwyndalf in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-13-2006, 08:20 PM
  5. How do I sort variables into sets of three?
    By mikeb in forum Excel General
    Replies: 2
    Last Post: 06-20-2006, 07:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1