Issue with Solver in Macro

Joined
Jul 17, 2010
Messages
1
Reaction score
0
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!

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
 

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