Share via


SolverAdd Function Example

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

This example uses the Solver functions to maximize gross profit in a business problem. The SolverAdd function is used to add three constraints to the current problem.

  Worksheets("Sheet1").Activate
SolverReset
SolverOptions precision:=0.001
SolverOK setCell:=Range("TotalProfit"), _
    maxMinVal:=1, _
    byChange:=Range("C4:E6")
SolverAdd cellRef:=Range("F4:F6"), _
    relation:=1, _
    formulaText:=100
SolverAdd cellRef:=Range("C4:E6"), _
    relation:=3, _
    formulaText:=0
SolverAdd cellRef:=Range("C4:E6"), _
    relation:=4
SolverSolve userFinish:=False
SolverSave saveArea:=Range("A33")