Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solver Table missing in Data Menu of Excel2003. Where is it? Guaylen Excel Worksheet Functions 2 November 14th 04 08:54 PM
Solver not Using Constraints when called from VB Mark[_47_] Excel Programming 0 July 8th 04 08:57 PM
Worksheet_Change sub does not trigger a called macro herman Excel Programming 3 February 8th 04 08:30 PM
Solver code does not save results to sheet - What am I missing?! Simon Livings Excel Programming 0 January 16th 04 03:55 PM
which FormField called a macro? Juggernath[_2_] Excel Programming 0 January 15th 04 12:58 PM


All times are GMT +1. The time now is 06:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"