2

I've looked through as many examples on here as I think there are but for some reason in my code the integer portion of it is being ignored. Underneath the 1st "SolverAdd, you'll see the other 2 that I've tried to use as well but each time the integer requirement is ignored. Any idea what I am doing wrong ? Thanks!

SolverReset
SolverOk SetCell:="$T$4", MaxMinVal:=1, ValueOf:=0, ByChange:="$R$8:$R$13" _
, Engine:=1, EngineDesc:="GRG Nonlinear"
'Solver ignores integer requirement for the reference range
SolverAdd CellRef:="$R$8:$R$13", Relation:=4, FormulaText:="integer"
'Have tried this: SolverAdd CellRef:="$R$8:$R$13", Relation:=4
'Have also tried this: SolverAdd CellRef:="$R$8:$R$13", Relation:=4, FormulaText:=0
SolverSolve True

Have also tried this:

SolverReset
SolverOk SetCell:="$T$4", MaxMinVal:=1, ValueOf:=0, ByChange:="$R$8:$R$13" _
, Engine:=1, EngineDesc:="GRG Nonlinear"
'Solver ignores integer requirement for the reference range
SolverAdd CellRef:=Range("$R$8:$R$13"), _
Relation:=4
SolverSolve True
3
  • In the Solver dialog, Options, All Methods, is "Ignore Integer Constraints" checked? Commented Sep 29, 2020 at 21:12
  • It is not checked, do I need to reset the options within the VBA for solver? Or do those options set there role over into the VBA automatically ? Commented Sep 29, 2020 at 21:13
  • This is so bizarre - I added another "SolverSolve" at the end of the statement and it is now keeping them as integers. However it is ignoring the MaxMinVal:= 1 criteria Commented Sep 29, 2020 at 21:19

1 Answer 1

1

I thought the constraint was built into the "MaxMinVal" portion of the solver code.

I manually added both constraints with the range of T4 being maxed a 1.000000000001 since just having "1" causes issues from what I've seen.

SolverReset
SolverOk SetCell:=Range("$T$4"), MaxMinVal:=1, ByChange:=Range("$R$8:$R$13") _
, Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:=Range("$R$8:$R$13"), _
Relation:=4
SolverAdd CellRef:=Range("$T$4"), _
Relation:=1, FormulaText:="1.00000000001"

FormulaText:=0 SolverSolve True

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.