-->
Defines a basic Solver model. Equivalent to clicking Solver in the Data | Analysis group and then specifying options in the Solver Parameters dialog box.
Note The Solver add-in is not enabled by default. Before you can use this function, you must have the Solver add-in enabled and installed. For information about how to do that, see Using the Solver VBA Functions. After the Solver add-in is installed, 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 Solver under Available References. If Solver does not appear under Available References, click Browse, and then open Solver.xlam in the Program FilesMicrosoft OfficeOffice14LibrarySOLVER subfolder.
SolverOk( SetCell, MaxMinVal, ValueOf, ByChange, Engine, EngineDesc)
If you’ve ever ventured into the Excel Solver add-in, you probably noticed that there are many options and it can be a little overwhelming. In this post, I’d like to provide some practical information to help you choose the correct solving method in Excel to efficiently find an optimum solution to your problem.
SetCell Optional Variant. Refers to a single cell on the active worksheet. Corresponds to the Set Target Cell box in the Solver Parameters dialog box.MaxMinVal Optional Variant. Corresponds to the Max, Min, and Value options in the Solver Parameters dialog box.
MaxMinVal | Specifies |
---|---|
1 | Maximize |
2 | Minimize |
3 | Match a specific value |
ValueOf Optional Variant. If MaxMinVal is 3, you must specify the value to which the target cell is matched.
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 Cells box in the Solver Parameters dialog box.
Engine Optional Variant. The Solving method that should be used to solve the problem: 2 for the Simplex LP method, 1 for the GRG Nonlinear method, or 3 for the Evolutionary method. Corresponds to the Select a Solving Method dropdown list in the Solver Parameters dialog box.
EngineDesc Optional Variant. An alternate way to specify the Solving method that should be used to solve the problem as a string: 'Simplex LP', 'GRG Nonlinear', or 'Evolutionary'. Corresponds to the Select a Solving Method dropdown list in the Solver Parameters dialog 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.
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.