Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Missing condition after solver called by macro
Hi there
I am trying to run the solver by using macro code. So far the solver is reacting and running properly (with the reference "Tools - References - Solver" activated), except one thing: After running the macro, I invoke the solver manually to check if the macro has set the correct solver settings. All is fine, but one condition is missing: Condition (1) is fine (restricting E9 to positive values), but condition (2) (restricting E9 to values less than 1) is missing. Any idea why? - Help greatly appreciated Sam samkut @ web.de Sub solver_macro() SolverReset SolverAdd CellRef:="$E$9", Relation:=3, FormulaText:="0" (1) SolverAdd CellRef:="$E$9", Relation:=1, FormulaText:="1" (2) SolverOk SetCell:="$F$4", MaxMinVal:=2, ValueOf:="0", ByChange:= _ "$E$9:$E$12,$E$14:$E$17,$F$32" SolverSolve UserFinish:=True End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Missing condition after solver called by macro
I'm having a very similar problem as Sam. I have four constraints, only three of which are being respected. The fourth is to keep a number <= 5. It's not syntax because of several reasons: - I've rearranged the code = No Good - I've copied and pasted knows good constraints = No Good - I've recorded a new macro and copied/pasted = No Good - Some numbers work: 4.9, 5.1 (any number w/ decimal) -5 (any negative number) 15, 16, 100 (any number 14) Here are the numbers that don't work: 1 - 14 (any positive integer less than 15) Here's my code: ' Select formula worksheet and reset initial state Sheets("13point").Select Range("D27").Select ActiveCell.FormulaR1C1 = "0" Range("D28").Select ActiveCell.FormulaR1C1 = "0" Range("D29").Select ActiveCell.FormulaR1C1 = "0" SolverReset SolverOptions Iterations:=100000 ' Set solver target and manipulation cells SolverOk SetCell:="$O$37", MaxMinVal:=2, ByChange:="$D$27:$D$29" ' Add formula/result constraints (Offset adjustment limits) SolverAdd CellRef:=Range("$J$45:$J$46"), Relation:=1, FormulaText:="0.7" ' Shift Upper Limit SolverAdd CellRef:=Range("$J$45:$J$46"), Relation:=3, FormulaText:="-0.7" ' Shift Lower Limit SolverAdd CellRef:="$J$47", Relation:=1, FormulaText:="5" ' 2FE Upper Limit SolverAdd CellRef:="$J$47", Relation:=3, FormulaText:="-5" ' 2FE Lower Limit ' Compute Solver solution, accept results, return to results worksheet SolverSolve UserFinish:=False ' [DELETE THIS FOR FINAL] ' SolverSolve UserFinish:=True [USE THIS FOR FINAL] Sheets("Limits Report 1").Select ' [DELETE THIS FOR FINAL] ' Sheets("13point - FINE").Select [USE THIS FOR FINAL] -- halfsoul ------------------------------------------------------------------------ halfsoul's Profile: http://www.excelforum.com/member.php...o&userid=34063 View this thread: http://www.excelforum.com/showthread...hreadid=492647 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Missing condition after solver called by macro
Any suggestions? -- halfsou ----------------------------------------------------------------------- halfsoul's Profile: http://www.excelforum.com/member.php...fo&userid=3406 View this thread: http://www.excelforum.com/showthread.php?threadid=49264 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Missing condition after solver called by macro
All, Sam solved our problems. Apparently, some graphics/pictures/graphs will cause the macro to ignore solver conditions involving positive integers less than 15. If that happens to you, delete any pictures/graphs one by one until your macro works. Once you have your picture(s) isolated, then you should be able to delete only the problem picture(s) and leave all the rest. If you can't live without the problem picture(s), the only other option is to change the number. For example, if your limit is supposed to be 5, instead use 4.9999999 -- halfsoul ------------------------------------------------------------------------ halfsoul's Profile: http://www.excelforum.com/member.php...o&userid=34063 View this thread: http://www.excelforum.com/showthread...hreadid=492647 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Solver Table missing in Data Menu of Excel2003. Where is it? | Excel Worksheet Functions | |||
Solver not Using Constraints when called from VB | Excel Programming | |||
Worksheet_Change sub does not trigger a called macro | Excel Programming | |||
Solver code does not save results to sheet - What am I missing?! | Excel Programming | |||
which FormField called a macro? | Excel Programming |