View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis[_3_] Dana DeLouis[_3_] is offline
external usenet poster
 
Posts: 690
Default Repeated application of Solver to new equations

You may want to consider these additional ideas with Solver...

Sub Demo()
Dim R As Long 'Row
Dim Results As Long

For R = 2 To 10
SolverReset
SolverOk _
SetCell:=Cells(R, 5).Address, _
MaxMinVal:=3, _
ValueOf:=0, _
ByChange:=Cells(R, 2).Address
Results = SolverSolve(True)
Select Case Results
Case 0, 1, 2
'Results should be valid
SolverFinish ' Keep results (default)
Case Else
'Your code here
'SolverFinish 2' You may want to discard results here
End Select
Next R

End Sub

= = = = = = =

Case 0,1,& 2 correspond to these messages...

Sub Demo2()
'// Dana DeLouis
Dim Result As Long

With Workbooks("SOLVER.XLA").Sheets("LANGUAGE")
For Result = 0 To 2
Debug.Print Result; .Cells(Result + 51, 1)
Next Result
End With
End Sub

Returns the following...

0 Solver found a solution. All constraints and optimality conditions are
satisfied.
1 Solver found a solution within tolerance. All constraints and optimality
conditions are satisfied.
2 Solver has converged to the current solution. All constraints are
satisfied.


--
Dana DeLouis
Win XP & Office 2003


"John Cordes" wrote in message
...
Tom Ogilvy wrote:
Maybe there is something useful in he

http://support.microsoft.com/support...ver/solver.asp
Creating Visual Basic Macros that Use Microsoft Excel Solver

Thank you, Tom. That looks to be a very comprehensive page - a lot of
reading required! The crucial step suggested there seems to be to use
SolverSolve UserFinish:=True
That prevents the Solver dialog box from popping up.

Progress is being made, thanks to you knowledgeble and generous folks
here.

John