Equivalent to choosing Range Analyze Solver... and pressing the Add button in the Solver Parameters dialog box. Adds a constraint to the current problem.
Syntax
SolverAdd(CellRef, Relation, FormulaText)
CellRef is a reference to a cell or a range of cells on the active worksheet and forms the left hand side of the constraint.
Relation specifies the arithmetic relationship between the left and right sides, or whether CellRef must have an integer value at the solution.
Relation Relationship
1 <=
2 =
3 >=
4 Int (CellRef is an integer variable)
5 Bin (CellRef is a binary integer variable)
FormulaText is the right hand side of the constraint and will often be a single number, but it may be a formula or a reference to a range of cells. If it is a formula, any cell references should have explicit sheet letters, such as "1+A:C1".
If Relation is 4 or 5, FormulaText is ignored, and CellRef must be a subset of the By Changing Cells.
If FormulaText is a reference to a range of cells, the number of cells in the range must match the number of cells in CellRef, although the shape of the areas need not be the same. For example, CellRef could be a row and FormulaText could refer to a column, as long as the number of cells is the same.
Remarks
The SolverAdd, SolverChange and SolverDelete functions correspond to the Add, Change, and Delete buttons in the Solver Parameters dialog box. You use these functions to define constraints. For many macro applications, however, you may find it more convenient to load the problem in a single step using the SolverLoad function.
Each constraint is uniquely identified by the combination of the cell reference on the left and the relationship (<=, =, >=, int or bin) between its left and right sides. This takes the place of selecting the appropriate constraint in the Solver Parameters dialog box. You can manipulate constraints with SolverChange and SolverDelete.