+ Reply to Thread
Results 1 to 4 of 4

Solver Resetting itself

  1. #1
    Registered User
    Join Date
    02-26-2023
    Location
    Australia
    MS-Off Ver
    365
    Posts
    2

    Unhappy Solver Resetting itself

    Hello,

    I've recently made a macro that utilizes solver to minimize a variable. There are a number of constraints that I had to use to get the results that I wanted.
    When I use solver initially (setting the macro) it works exactly how I want .
    But after running the macro after setting it loses most of the constraints that I have applied and the answer is not what I am after .
    When setting the macro I make sure to hit the reset all button on solver before entering the constraints just to be safe.

    Any idea why this is happening and how do I solve this?

    I've made a simple spreadsheet to show what is happening and what I am trying to achieve;
    In this case I am trying to choose the best shop to go to by maximizing items
    Initially my macro included a constraint for fruit and chocolate but after running it through the button it deletes the constraint for chocolate and just goes for the maximum

    Thanks
    Attached Files Attached Files
    Last edited by Joebally; 02-27-2023 at 02:30 AM. Reason: Adding Excel File

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Solver Resetting itself

    Perhaps this could explain your problem?

    In the uploaded file the command "SolverReset" is placed before the building of the solver model. Checking the solver setup after the macro you will see the solver setting used in this setup.

    But if you move the "SolverReset" command to the end of the macro i.e.

    Please Login or Register  to view this content.
    then the there will be no solver setting if you open solver after the run.

    Alf
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    02-26-2023
    Location
    Australia
    MS-Off Ver
    365
    Posts
    2

    Re: Solver Resetting itself

    Hey Alf,

    Thanks for the help but unfortunately this solution did not work
    I've attached a sample code that will hopefully help solve this issue

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Solver Resetting itself

    I did have som problem with your file as solver in an Scandinavian environment didn't did not work with your costs expressed as $4.00

    I also modified your setup a bit as I setup the problem a simplex one.

    Maximum chocolate is the driving force. You could change the total cost = 20 instead of my =< 20 it will not give you more chocolate but perhaps your mom will by happy as you saved her a dollar.

    The only thing I'm not sure about are two fruits. Could they be the same or must it be different fruits?

    If so you could sum the fruit range F5:H5 and set the sum to be "<=1" and do the same for range F6:H6 and range F7:H7 .

    If you do change the setup you then need to add this line to the macro before the line "SolverSolve" line in order to add this constraint in the building of the solver macro.

    Please Login or Register  to view this content.
    Alf
    Attached Files Attached Files
    Last edited by Alf; 02-27-2023 at 03:11 PM. Reason: correcting wrong info about binaries

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. SOLVER Error Message: excel solver objective cell contents must be a formula
    By bluevil in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-03-2022, 05:38 AM
  2. Replies: 5
    Last Post: 10-09-2020, 03:33 AM
  3. Replies: 2
    Last Post: 06-22-2020, 03:14 PM
  4. Replies: 7
    Last Post: 12-31-2016, 12:29 PM
  5. Replies: 0
    Last Post: 07-20-2014, 12:45 PM
  6. Can't start Solver. Error message says Solver.xlam already open.
    By DaveHills in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 1
    Last Post: 10-21-2012, 11:02 AM
  7. solver macro + simulation code + not updating solver values
    By sabinemaria in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2012, 11:37 AM

Tags for this Thread

Bookmarks

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