Hello Excel VBA experts,
I have a multi-variable problem with multiple constraints that is solved successfully and quickly with SOLVER directly in Excel. However, I have the following issues when trying to do the same within a loop in VBA.
Firstly, recording a macro while executing SOLVER was little help for determining the proper syntax. I pieced code together from examaples found on-line.
I do have a reference set to SOLVER within VBA by Tools<References<check the "solver" box. However, I get compile errors using lines like:
If I preceed the solver commands with Application.Run, put the commands within quotes, and omit the text preceeding the arguments (SetCell:=, for example), I avoid the compile errors. Here is my code:Please Login or Register to view this content.
Each line executes, but an "error in model" is generated after the first SolverSolve command.Please Login or Register to view this content.
Why do I need Application.Run?
What is wrong with the syntax in my example? The column references in the SolverAdd commands are correct.
I'm using Excel 2010 with Windows XP if that matters.
Thanks for suggestions.
Bookmarks