Use the same technique as I used in the macro to set the X4:X?? range and use another letter say j to be dimmed as an Integer. And this constraint needs to be set when the solver model is build by the macro the same way as the range X4:X? is set up
if i add some more constraint in the future, what is the easiest way to add constraints as code in macro ?
Just write it in as a "SolverAdd CellRef:=" line where you add a relation i.e.
tells solver that the range X4:X? should be equal to or less 20. Relation:=2 means equal to and Relation:=3 means equal to or greater than a specified value. Relation:=4, FormulaText:="integer" sets the result in that specified range to integers and Relation:=5, FormulaText:="binary" sets the result to the specified range to binary values.
You can also specify a range
were the result values in E12:G12 should be equal to or less than the values in E11:G11
Testing the model a bit more I also got the ''Solver encountered an error value in the objective cell or a constraint cell', but part of the problem seems to be some underlying calculation so I pressed F9 to get excel to calculate the workbook and ded a solver rerun and that did work.
What seems to be important is that the range X4:X? should be equal to or less than the T4:T? range if it's greater you do get some funny results in the AD column. Could be fixed in the macro by adding this line.
or you do it manually.
sorry because model is in my language,
Don't worry, this was more a bit of a warning that since I do not understand the language I could not work out how things interacted so it could be my macro made a mess of resuts elsewhere as there are quite a number of macros in your uploaded file.
Alf
Bookmarks