# Excel Solver Less Than or Equal To Constraint

1. ## Excel Solver Less Than or Equal To Constraint

Hello all,
I have some vba code to solve my system. Two of the constraints require variable values to be less than or equal to another cell value. However, for some reason solver always forces the variables to be equal to the other cell value instead of allowing it to be less than as well.
In the code below, the Var7 and Var8 are the variables forced to be equal to ConstraintValue2 instead of allowed to be less than. Anyone have any tips or ideas? Thanks in advance.

``Please Login or Register  to view this content.``

2. ## Re: Excel Solver Less Than or Equal To Constraint

I don't see anything in the code itself that would cause Solver to explain your question. My guess is that something in the mathematical model you are working with causes Solver to conclude that the minimum value for Result2 is always at the maximum values for Var7 and Var8. Have you analyzed your problem enough to know whether this is true or not? I don't think this will be something we can analyze on this side of the internet (unless you share the mathematical model you are trying to solve).

3. ## Re: Excel Solver Less Than or Equal To Constraint

Do CostraintValue2 or ConstraintValue2 change in the course of the solution? They are only evaluated once.

Notice you have two different spellings.

4. ## Re: Excel Solver Less Than or Equal To Constraint

shg,
Sorry that was just a typing error when I was changing the names to post on here. Those two should be the same. Their values do not change in the course of the solution.
MrShorty,
There shouldn't be anything in the model that would cause solver to think that, but I will go through it and see if I notice anything.
Thanks

5. ## Re: Excel Solver Less Than or Equal To Constraint

BTW, in SolverAdd, FormulaText is redundant to Relation, as is EngineDesc to Engine in SolverOK.

6. ## Re: Excel Solver Less Than or Equal To Constraint

Follow-up:
I looked into the program and found two errors. The first was the way I was referencing cells on a different sheet. Solver didn't like that for some reason. The second error was the greater than or equal to constraint. The way the mathematical model works solver should have set the greater than or equal to variable (Result1) to the lowest value possible in order to minimize Result2 the overall objective of the solver. However, since there was no upper bound on Result1 solver instead choose to maximize Var7 and Var8 which resulted in Result1 being higher than necessary. I created a cell to calculate the error in Result1 and constrained it to zero and that fixed my issue.

Thanks for the replies.

7. ## Re: Excel Solver Less Than or Equal To Constraint

Yep, they all must be on the same sheet.

Also, the SolverOK statement should appear before the SolverAdd statements.

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1