Results 1 to 2 of 2

Thread: Solver: Constraint for values in a range
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Aug 2018
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Solver: Constraint for values in a range

    Hi

    I am looking to add a constraint where the output is within a range of -0.1 and +0.1.

    I have the following code set up which satisfies the +0.1 constraint. Is there a way to impose the second constraint to define the range?

    Thanks

    SolverOk SetCell:="$B$94", MaxMinVal:=2, ValueOf:=0, ByChange:="$AJ$55:$AJ$84", _
    Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverAdd CellRef:="$B$91", Relation:=2, FormulaText:=Sheets("GLOB").Range("$AQ$15").Offset(i, 0).Address
    SolverOk SetCell:="$B$94", MaxMinVal:=2, ValueOf:=0, ByChange:="$AJ$55:$AJ$84", _
    Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverAdd CellRef:="$AJ$87", Relation:=2, FormulaText:="=1"
    SolverOk SetCell:="$B$94", MaxMinVal:=2, ValueOf:=0, ByChange:="$AJ$55:$AJ$84" _
    , Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverOk SetCell:="$B$94", MaxMinVal:=2, ValueOf:=0, ByChange:="$AJ$55:$AJ$84", _
    Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverAdd CellRef:="$AJ$55:$AJ$84", Relation:=1, FormulaText:="=0.1"
    SolverOk SetCell:="$B$94", MaxMinVal:=2, ValueOf:=0, ByChange:="$AJ$55:$AJ$84", _
    Engine:=1, EngineDesc:="GRG Nonlinear"

  2. #2
    MrExcel MVP shg's Avatar
    Join Date
    May 2008
    Location
    The Great State of Texas
    Posts
    21,612
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    14 Thread(s)

    Default Re: Solver: Constraint for values in a range

    Code:
      SolverOk SetCell:="B94", _
               MaxMinVal:=2, _
               ValueOf:=0, _
               ByChange:="AJ55:AJ84", _
               Engine:=1
      SolverAdd CellRef:="AJ55:AJ84", _
                Relation:=1, _
                FormulaText:="=0.1"
      SolverAdd CellRef:="AJ55:AJ84", _
                Relation:=3, _
                FormulaText:="=-0.1"
      SolverAdd CellRef:="B91", _
                Relation:=2, _
                FormulaText:=Range("AQ15").Offset(i, 0).Address
      SolverAdd CellRef:="AJ87", _
                Relation:=2, _
                FormulaText:="=1"

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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