Solver not Using Constraints when called from VB

M

Mark

I have vb code I am running in excel that calls solver for each row in
a spreadsheet. Sometimes solver works correctly and other times it
runs but ignores the constraints. I am using Microsoft Excel 2002. I
have read that when referencing cells in Solver through VB for
versions after Excel 97 you need to use A1 notation. In my code I am
referencing the cells used in the constraints with variables. Below I
have a small example of some of the code I am using. I am
particularly perplexed because of the intermittent nature of the
problem. Any help would be greatly appreciated.

minCol = "AL"
maxCol = "AM"

SolverReset
SolverOk SetCell:=Range(profitCol & row), MaxMinVal:=1, _
ByChange:=Range(priceCol & row)
SolverOptions MaxTime:=100, Iterations:=100,
Precision:=0.000001, AssumeLinear :=False, StepThru:=False,
Estimates:=1, Derivatives:=1, _ SearchOption:=1, _
IntTolerance:=5, Scaling:=False, Convergence:=0.0001, _
AssumeNonNeg:=False


SolverAdd CellRef:=Range(priceCol & row), Relation:=3, _
FormulaText:=Range(minCol & row)

SolverAdd CellRef:=Range(priceCol & row), Relation:=1, _
FormulaText:=Range(maxCol & row)

SolverAdd CellRef:=Range(qtyCol & row), Relation:=3, _
FormulaText:=0

SolverSolve UserFinish:=True

SolverFinish KeepFinal:=1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top