SolverAdd Function

See Also         Example

Adds a constraint to the current problem. Equivalent to clicking Solver on the Tools menu and then clicking Add in the Solver Parameters dialog box.

Before you use this function, you must establish a reference to the Solver add-in. With a Visual Basic module active, click References on the Tools menu, and then select the Solver.xla check box under Available References. If Solver.xla doesn't appear under Available References, click Browse and open Solver.xla in the \Office\Library subfolder.

Syntax

SolverAdd(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 shouldn’t 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.

FormulaText   Optional Variant. The right side of the constraint.

Remarks

After constraints are added, you can manipulate them with the SolverChange and SolverDelete functions.