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 |
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 |
All times are GMT +1. The time now is 10:40 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com