The way to do this is to create a cell with the sum and then use Solver.SolverAdd to add a constraint. The complete call can look like:
Unfortunately (for me) this did not work and I see:Call Solver.SolverAdd(CellRef:=sumcell, Relation:=2, FormulaText:=1)
After much experimentation I used instead:
Call Solver.SolverAdd(CellRef:=sumcell, Relation:=2, FormulaText:=0.999999999999999)Now I see:
How in the world can such a bug be introduced? Some bugs make sense, but the logic of this one is difficult to fathom. I cannot but think there must be a statement somewhere:
if rhs=1 and (not interactive) and (user=’Erwin.Kalvelagen’) thenSolver works correctly with a =1 equation when used from the GUI.
call delete_constraint_to_confuse_user
Well, found some more reports on this strange bug:
- http://www.pcreview.co.uk/forums/problem-solveradd-can-anyone-help-t961905.html
- http://excelforum.com/excel-programming-vba-macros/492647-solved-missing-condition-after-solver-called-by-macro.html
- http://stackoverflow.com/questions/15620177/excel-solver-ignoring-constraint-in-vba
This bug is present in Excel 2010 and 2013 (32 and 64 bit).
Does FormulaText:=1.0 make a difference?
ReplyDeleteNo difference: also ignored.
ReplyDelete