+ Reply to Thread
Results 1 to 6 of 6

VBA script for running Solver in loop

  1. #1
    Registered User
    Join Date
    10-31-2011
    Location
    Outside US
    MS-Off Ver
    Excel 2007
    Posts
    3

    VBA script for running Solver in loop

    I am running a VBA script for running solver in loop. The code looks as follows:
    Please Login or Register  to view this content.
    The problem is that each time the solver finishes solving, it invokes a dialog box which asks me if I would like to keep the solution or restore to original values. This means I have to press enter each time the solver solves. I have to use the solver in a loop for 2000 times, which means I have to press enter 2000 times. Is there any way I can automate this pressing Enter part?
    ~Thanks in advance.
    Last edited by confusedguy; 10-31-2011 at 04:01 AM.

  2. #2
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: VBA script for running Solver in loop

    Application.DisplayAlerts = false

    Don't forget to turn it back on when done
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  3. #3
    Registered User
    Join Date
    10-31-2011
    Location
    Outside US
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VBA script for running Solver in loop

    Hi Foxguy,
    I tried adding your code before the loop, in the loop before solver solve and after solver solve, but it did not help.
    Am I missing something?

  4. #4
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: VBA script for running Solver in loop

    I don't know. It's always worked for me, to tell Excel to always use the Default Answer.
    I'll have to test it to see what's going on. I'll let you know what I find.

  5. #5
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: VBA script for running Solver in loop

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-31-2011
    Location
    Outside US
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VBA script for running Solver in loop

    Thanks a lot! This code works fine. I did try using SolverFinish keepFinal:=1 earlier, but I had not written userFinish:=True. Now it is working perfectly!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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