GuyPrall5963
New Member
- Joined
- Sep 2, 2009
- Messages
- 1
The code below is part of a macro that programmatically sets criteria in Solver and runs Solver. The process has appeared to have worked perfectly for multiple machines and versions of Excel for about a year. I am using Excel 2003. However, I have come across an error that I cannot fathom. When the value in the cell that is referenced by "Sheet5.Cells(9, 2)" is either the number 8 or the number 9, this criterion is not added! I can plug in, say "6" or "10" or indeed any other number, and the criterion is added - but not with 8 or 9.
Even if I use the more normal code of
... it still fails to add the criterion if the cell value is 8 or 9.
If I manually set criteria using the Solver toolbar, there is no problem with it accepting the values of 8 or 9 as a constraint, naturally. Since this particular constraint is "price not greater than" it is causing me significant issues since, if this constraint is not included, Solver assumes that price is not an issue so gives me very expensive solutions! Interestingly this issue has arisen as a result of the recession - we have never had to set the maximum price level as low as 8 or 9!
Does anyone have any insights into what might be going on?
Code:
Application.Run "Solver.xla!SolverAdd", _
Sheet1.Cells(1, 3), _
Sheet1.Cells(2, 3), _
Sheet5.Cells(9, 2)
Even if I use the more normal code of
Code:
SolverAdd CellRef:=Sheet1.Cells(1, 3), _
Relation:=Sheet1.Cells(2, 3), _
FormulaText:=Sheet5.Cells(9, 2)
... it still fails to add the criterion if the cell value is 8 or 9.
If I manually set criteria using the Solver toolbar, there is no problem with it accepting the values of 8 or 9 as a constraint, naturally. Since this particular constraint is "price not greater than" it is causing me significant issues since, if this constraint is not included, Solver assumes that price is not an issue so gives me very expensive solutions! Interestingly this issue has arisen as a result of the recession - we have never had to set the maximum price level as low as 8 or 9!
Does anyone have any insights into what might be going on?
Last edited: