mdavide
Board Regular
- Joined
- Oct 19, 2004
- Messages
- 211
Hi
I've some strange problems with SOLVER in VBA: I wrote the code in order to solve iterativly a problem; the macro tries to solve the problem and eventually adds or removes specific constraints automatically...
BUT there are problems with a few constraints that are added via VBA but don't affect the linear problem.
these constraints sound like this
It seems to me a simple constraint (constraint.address is a sinle cell reference) and I don't know why it does't work when others work correctly, that is the constraint doesn't appear in the list and the linear ploblem is not affected.
strangeness of these problems is the following:
- the code run without error messages, it seems to work correctly; other constraints are added
- when I try to add these constraints manually, they appears in the constraints list and the linear problem works correctly
- when I change the value of FormulaText in 6,7,8.... the constraint is added in the list (it seems not to work with these values 1,2,3,4,5) (...but my goal remains only the number 3)
- I can't use a variable 'cause it does't work
the last strange thing:
initially, I wrote the "solver" code in a separate module and in a separate workbook, and there it works perfectly, without the problems I mentioned before. when I copy the code in a bigger simulation program (that solver should be the last part), in a new module, the solver does't work like I want with the problems that I explained before.
Does anyone know about this kind of problem? Are there conflicts or bugs in VBA with solver? I'm glad to receive any type of suggestions
thanks
DM
I've some strange problems with SOLVER in VBA: I wrote the code in order to solve iterativly a problem; the macro tries to solve the problem and eventually adds or removes specific constraints automatically...
BUT there are problems with a few constraints that are added via VBA but don't affect the linear problem.
these constraints sound like this
Code:
SolverAdd CellRef:=constraint.address, Relation:=3, FormulaText:=3
It seems to me a simple constraint (constraint.address is a sinle cell reference) and I don't know why it does't work when others work correctly, that is the constraint doesn't appear in the list and the linear ploblem is not affected.
strangeness of these problems is the following:
- the code run without error messages, it seems to work correctly; other constraints are added
- when I try to add these constraints manually, they appears in the constraints list and the linear problem works correctly
- when I change the value of FormulaText in 6,7,8.... the constraint is added in the list (it seems not to work with these values 1,2,3,4,5) (...but my goal remains only the number 3)
- I can't use a variable 'cause it does't work
the last strange thing:
initially, I wrote the "solver" code in a separate module and in a separate workbook, and there it works perfectly, without the problems I mentioned before. when I copy the code in a bigger simulation program (that solver should be the last part), in a new module, the solver does't work like I want with the problems that I explained before.
Does anyone know about this kind of problem? Are there conflicts or bugs in VBA with solver? I'm glad to receive any type of suggestions
thanks
DM