Skip to main content

SolverChange Function

Table of contents
  1. Syntax
  2. Remarks
  3. Example

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


SolverChange( CellRefRelationFormulaText)

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.

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

FormulaText Optional Variant. The right side of the constraint.


If CellRef and Relation don't match an existing constraint, you must use the SolverDelete and SolverAdd functions to change the constraint.


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

SolverLoad loadArea:=Range("A33:A38")
SolverChange cellRef:=Range("C4:E6"), relation:=3, formulaText:=1
SolverSolve userFinish:=False

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>