View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
halfsoul halfsoul is offline
external usenet poster
 
Posts: 1
Default 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