Need advice on Solver loop

R

robs3131

Hi,

I have a loop that executes Solver -- I have the following questions:

1 - It appears that once Solver is first set up to run, it stores the values
and constraints so that if they are not changed, it will keep those initial
values. Assuming this is correct and given that I am referencing cells on my
sheet that change in value with each instance of the loop, I'm thinking that
all I need to do is set up Solver once in my code for it's initial run and
then just have it execute each time it loops through. Does this sound right
to you? Below is my Solver code within the loop.

SolverOk SetCell:="$AF$1", MaxMinVal:=2, ValueOf:="0", _
ByChange:="payfclearbin"
SolverAdd CellRef:="payfclearbin", Relation:=5, FormulaText:="binary"
SolverAdd CellRef:="$AE$1", Relation:=2, FormulaText:=Range("AD1").Value
SolverSolve userfinish:=True

2 - Just in case I need to, if I wanted to delete all prior constraints
("Cellref"), is there a way to have all constraints deleted at once rather
than deleting each individual constraint one by one?


Thanks!

Robert
 
D

Dana DeLouis

is there a way to have all constraints deleted at once rather
than deleting each individual constraint one by one?

Hi. Just my opinion is that it's hard to keep track on Constraints to
delete them 1 by 1.
I find it easier to just do a "Reset".

SolverReset
SolverOk SetCell:="AF1", MaxMinVal:=2, ByChange:="PayfClearBin"

Now, you are back to normal with no constraints.

(Note: you can drop the =0 since it's ignored)
 

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