Excel Reference

SolverChange Function

Changes an existing constraint. Equivalent to clicking Solver in the Data | Analysis group and then clicking Change in the Solver Parameters dialog box.

Note The Solver add-in is not enabled by default. Before you can use this function, the Solver add-in must be 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.

SolverChange( _CellRef_, _Relation_, _FormulaText_)

CellRef Required Variant. A reference to a cell or a range of cells that forms the left side of a constraint. Relation Required Integer. The arithmetic relationship between the left and right sides of the constraint. If you choose 4 or 5, _CellRef_ must refer to adjustable (changing) cells, and _FormulaText_ should not be specified.

RelationArithmetic relationship
1<=
2=
3>=
4Cells referenced by _CellRef_ must have final values that are integers.
5Cells referenced by _CellRef_ must have final values of either 0 (zero) or 1.
6Cells referenced by _CellRef_ must have final values that are all different and integers.

FormulaText Optional Variant. The right side of the constraint.

Remarks

If _CellRef_ and _Relation_ don’t match an existing constraint, you must use the SolverDelete and SolverAdd functions to change the constraint.

Example

This example loads the previously calculated Solver model stored on Sheet1, changes one of the constraints, and then solves the model again.

vb Worksheets("Sheet1").Activate SolverLoad loadArea:=Range("A33:A38") SolverChange cellRef:=Range("F4:F6"), _ relation:=1, _ formulaText:=200 SolverSolve userFinish:=False

!include[Support and feedback]

6 community Q&A using SolverChange Function

294 words2 sectionsMicrosoft Docs rev. 06/08/2017