View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
zaina zaina is offline
external usenet poster
 
Posts: 1
Default Solver: 2nd function of SolverSolve


Hello. New guy here so please be gentle. :)

From searching the internet, I've learned that the 2nd function of
SolverSolve can be called to count the number of iterations performed
by Solver, ie:

SolverSolve (1st_function, 2nd_function).


Here's the code I found, however I can not make it to run. Where do I
put the code in the VBA program? I mean what would be the complete
SolverSolve command?


Code:
--------------------
Global count as integer

Sub test()
count = 0
ret = solveroptions(stepthru:=True) '"checks" the Show Iteration checkbox in Tools/Solver/Options
ret = solversolve(True, "showtrial")
MsgBox count
End Sub

Function showtrial(reason As Integer)
If reason = 1 Then 'reason = 1 means that the function will be called on each iteration.
count = count + 1 'increments global variable
End If
showtrial = 1 ' continues Solver
End Function
--------------------


Thanks in advance!


--
zaina
------------------------------------------------------------------------
zaina's Profile: http://www.excelforum.com/member.php...o&userid=24316
View this thread: http://www.excelforum.com/showthread...hreadid=379230