SolverOk Function
Defines a basic Solver model. Equivalent to clicking Solver in the Data | Analysis group and then specifying options in the Solver Parameters dialog box.
Before you use this function, you must establish a reference to the Solver add-in. In the Visual Basic Editor, with a module active, click References on the Tools menu, and then select the Solver.xlam check box under Available References. If Solver.xlam does not appear under Available References, click Browse and open Solver.xlam in the \office12\library\Solver subfolder.
SolverOk(SetCell, MaxMinVal, ValueOf, ByChange)SetCell Optional Variant. Refers to a single cell on the active worksheet. Corresponds to the Set Target Cellbox in the Solver Parametersdialog box.
MaxMinVal Optional Variant. Corresponds to the Max, Min, and Valueoptions in the Solver Parametersdialog box.
| MaxMinVal | Specifies |
|---|---|
| 1 | Maximize |
| 2 | Minimize |
| 3 | Match a specific value |
ByChange Optional Variant. The cell or range of cells that will be changed so that you will obtain the desired result in the target cell. Corresponds to the By Changing Cellsbox in the Solver Parametersdialog box.
Example
This example uses the Solver functions to maximize gross profit in a business problem. The SolverOK function defines a problem by specifying the SetCell, MaxMinVal, and ByChange arguments.
|