Description
Begins a Solver solution run. The equivalent of clicking Solve in the Solver Parameters dialog box.
Before you use this function, you must establish a reference to the Solver add-in. With a Visual Basic module active, click References on the Tools menu, and then select the Solver.xla check box in the Available References box. If Solver.xla doesn't appear in the Available References box, click Browse, click Solver in the \Excel\Library\Solver folder, and then click OK.
Syntax
SolverSolve(userFinish, showRef)
userFinish
Optional. If True, returns the results without displaying the Solver Results dialog box. If False or omitted, returns the results and displays the Solver Results dialog box.
showRef
Optional. Used only if True is passed to the stepThru argument of the solverOptions function. You can pass the name of a macro (as a string) as the showRef argument. This macro is then called whenever Solver returns an intermediate solution.
See Also
SolverOk Function.
Example
This example uses the Solver functions to maximize gross profit in a business problem. The SolverSolve function begins the Solver solution run.
Worksheets("Sheet1").Activate SolverReset SolverOptions precision:=0.001 SolverOK setCell:=Range("TotalProfit"), _ maxMinVal:=1, _ byChange:=Range("C4:E6") SolverAdd cellRef:=Range("F4:F6"), _ relation:=1, _ formulaText:=100 SolverAdd cellRef:=Range("C4:E6"), _ relation:=3, _ formulaText:=0 SolverAdd cellRef:=Range("C4:E6"), _ relation:=4 SolverSolve userFinish:=False SolverSave saveArea:=Range("A33")