Adding multiple solver conditions in VBA

Joined
Sep 10, 2006
Messages
4
Reaction score
0
I am having trouble adding more than one condition to solver in VBA
When I run the following only the first condition is added. - If I rerun it then the first condition appears twice. (Note - this code was generated in Learn Mode)

Can anyone suggest what is wrong.

Sub solver4()
SolverOk SetCell:="$B$33", MaxMinVal:=1, ValueOf:="0", ByChange:="$B$28:$G$28"
SolverAdd CellRef:="$B$28:$G$28", Relation:=3, FormulaText:="0"
SolverOk SetCell:="$B$33", MaxMinVal:=1, ValueOf:="0", ByChange:="$B$28:$G$28"
SolverAdd CellRef:="$H$28", Relation:=2, FormulaText:="1"
SolverOk SetCell:="$B$33", MaxMinVal:=1, ValueOf:="0", ByChange:="$B$28:$G$28"
SolverAdd CellRef:="$B$28:$G$28", Relation:=1, FormulaText:="1"
SolverOk SetCell:="$B$33", MaxMinVal:=1, ValueOf:="0", ByChange:="$B$28:$G$28"
SolverSolve
End Sub



Thanks
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top