Hi all,
I am having an issue when using solver from a macro that is invoked by clicking a button.
It looks like that my second constraint is not picked-up by solver.
If I record the macro and do not use the SolvReset function all looks ok, then as soon as I add the SolvReset function only the first constraint that I add is picked-up.
I am using Excel 2007 and would really much appreciate if you guys can help out!!
Many thanks!
I am having an issue when using solver from a macro that is invoked by clicking a button.
It looks like that my second constraint is not picked-up by solver.
If I record the macro and do not use the SolvReset function all looks ok, then as soon as I add the SolvReset function only the first constraint that I add is picked-up.
I am using Excel 2007 and would really much appreciate if you guys can help out!!
Many thanks!
Code:
Sub min_risk_portfolio()
'
' min_risk_portfolio Macro
'
'
'
SolverReset
SolvOk SetCell:="$F$45", MaxMinVal:=2, ValueOf:="0", ByChange:="$F$36:$F$42"
SolvAdd CellRef:="$F$36:$F$42", Relation:=3, FormulaText:="0"
SolvOk SetCell:="$F$45", MaxMinVal:=2, ValueOf:="0", ByChange:="$F$36:$F$42"
SolvAdd CellRef:="$F$43", Relation:=2, FormulaText:="1"
SolvOk SetCell:="$F$45", MaxMinVal:=2, ValueOf:="0", ByChange:="$F$36:$F$42"
SolvSolve
End Sub