Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need advice on Solver loop
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 -- Robert |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need advice on Solver loop
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) -- HTH Dana DeLouis "robs3131" wrote in message ... 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 -- Robert |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Interesting Solver problem (Solver encounters an error) | Excel Discussion (Misc queries) | |||
Automating Solver in loop | Excel Programming | |||
Error message when using the Solver in a VBA macro loop | Excel Programming | |||
Resetting Solver Manually to Fix Solver Bug | Excel Programming | |||
Advice about loop and cell action | Excel Programming |