Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Solver constraints not added
This is driving me crazy. Trying to use Excel's solver, using the
following code: Sub findshiftconversion() SolverReset SolverOk SetCell:="Gfinal", MaxMinVal:=2, ByChange:="SHconv" SolverAdd CellRef:="SHconv", Relation:=1, FormulaText:=1 MsgBox (solverget(5, "sheet1")) SolverAdd CellRef:="SHconv", Relation:=3, FormulaText:=0 MsgBox (solverget(5, "sheet1")) SolverSolve End Sub SHconv and Gfinal are single-cell named ranges on sheet1. The proper reference to solver.xla has been set. The code executes, but refuses to put in the first constraint (i.e., the first SolverAdd statement doesn't do anything). This is obvious from the solverget values, which return 0 on first call, and 1 on second call. The same happens when I record the macro - Excel puts in extra junk and doesn't name the ranges in the code, but it amounts to a similar macro. It does what it needs to do when I record the macro, but doesn't work when I try to replay it. (The constraint is essential, otherwise Excel gets into numerical problems). Anyone know how to get around this? Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Solver constraints not added
Don't know, so just a guess.
XL2000: The Solver Add-in May Not Work When You Start Solver by Using a Macro http://support.microsoft.com/default...30&Product=xlw HTH. -- Dana DeLouis Using Windows XP & Office XP = = = = = = = = = = = = = = = = = "Rob" wrote in message om... This is driving me crazy. Trying to use Excel's solver, using the following code: Sub findshiftconversion() SolverReset SolverOk SetCell:="Gfinal", MaxMinVal:=2, ByChange:="SHconv" SolverAdd CellRef:="SHconv", Relation:=1, FormulaText:=1 MsgBox (solverget(5, "sheet1")) SolverAdd CellRef:="SHconv", Relation:=3, FormulaText:=0 MsgBox (solverget(5, "sheet1")) SolverSolve End Sub SHconv and Gfinal are single-cell named ranges on sheet1. The proper reference to solver.xla has been set. The code executes, but refuses to put in the first constraint (i.e., the first SolverAdd statement doesn't do anything). This is obvious from the solverget values, which return 0 on first call, and 1 on second call. The same happens when I record the macro - Excel puts in extra junk and doesn't name the ranges in the code, but it amounts to a similar macro. It does what it needs to do when I record the macro, but doesn't work when I try to replay it. (The constraint is essential, otherwise Excel gets into numerical problems). Anyone know how to get around this? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Set solver constraints so variables are either 1 OR 0. | Excel Worksheet Functions | |||
Solver Constraints | Excel Discussion (Misc queries) | |||
Excel Solver constraints | Excel Worksheet Functions | |||
Excel Solver Constraints | Excel Discussion (Misc queries) | |||
Solver Constraints | Excel Discussion (Misc queries) |