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. Each function corresponds to an action that you can perform interactively, through the Solver Parameters, Solver Options, and Solver Results dialog boxes of the Solver add-in. The following functions can be used to control the Solver add-in from VBA. If Solver does not appear under Available References, click Browse, and then open Solver.xlam in the \Program Files\Microsoft Office\Office14\Library\SOLVER subfolder. In the Visual Basic Editor, with a module active, click References on the Tools menu, and then select Solver under Available References. In the Add-Ins dialog box, select Solver Add-in, and then click OK.Īfter you have enabled the Solver add-in, Excel will auto-install the Add-in if it is not already installed, and the Solver command will be added to the Analysis group on the Data tab in the ribbon.īefore you can use the Solver VBA functions in the Visual Basic Editor, you must establish a reference to the Solver add-in. In the Manage drop-down box, select Excel Add-ins, and then click Go. In the Excel Options dialog box, click Add-Ins. 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.Before you can use the Solver VBA functions from VBA, you must enable the Solver add-in in the Excel Options dialog box.Ĭlick the File tab, and then click Options below the Excel tab. SolverOK setCell:=Range("TotalProfit"), _ The SolverAdd function is used to add three constraints to the current problem. This example uses the Solver functions to maximize gross profit in a business problem. RemarksĪfter constraints are added, you can manipulate them with the SolverChange and SolverDelete functions.
For this example, check 'Solver Add-In' and click 'OK.' After you click 'OK,' Excel 2019 installs the Solver add-in and it can now be used with the Goal Seek tool. RelationĬells referenced by CellRef must have final values that are integers.Ĭells referenced by CellRef must have final values of either 0 (zero) or 1.Ĭells referenced by CellRef must have final values that are all different and integers.įormulaText Optional Variant. Check the box next to the add-ins that you want to install. If you choose 4, 5, or 6, CellRef must refer to decision variable cells, and FormulaText should not be specified. The arithmetic relationship between the left and right sides of the constraint. A reference to a cell or a range of cells that forms the left side of a constraint. SolverAdd( CellRef, Relation, FormulaText)ĬellRef Required Variant. After the Solver add-in is installed, you must establish a reference to the Solver add-in.
ADD SOLVER FOR EXCEL HOW TO
For information about how to do that, see Using the Solver VBA Functions. Before you can use this function, the Solver add-in must be enabled and installed. Note The Solver add-in is not enabled by default. Equivalent to clicking Solver in the Data | Analysis group and then clicking Add in the Solver Parameters dialog box. Adds a constraint to the current problem.