SOLVER conflicts in VBA? strange bugs?

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

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
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Could be that the values (1,2,3,4,5) can't be interpret in the right way cause they are the "Relation" constants, that is:

1 = less than or equal
2 = equal
3 = greater than or equal
4 = integer
5 = binary

?????

suggestions? tips? everything else? .... please answer me if you know

DM
 
Upvote 0

Forum statistics

Threads
1,216,322
Messages
6,130,045
Members
449,554
Latest member
andyspa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top