How do I use Open Solver in Excel using VBA

I have a problem that has a lot of variables and the normal excel solver takes a lot of time to solve the problem. I am using the excel opensolver as it is faster and more efficient. I tried to record a macro but could not see any code related to opensolver. I need to access open solver using VBA just like we do for normal excel solver.

Thanks in advance!

Upvotes: 2

Views: 6605

Answers (2)

Andrew
Andrew

Reputation: 11

OpenSolver does not have any ability to record macros; it is not a feature our users have ever requested. However it does have a well documented VBA interface; see http://opensolver.org under Using OpenSolver.

Upvotes: 1

Ru Hasha
Ru Hasha

Reputation: 956

This is how I got it working for a toy optimization problem I just created:

  • Add the Opensolver reference to your VB project

References menu...

OpenSolver reference

  • Call the solver as in this example code:

    Sub Test_OpenSolver()
        OpenSolver.RunOpenSolver , False
        'Q: Why False as a Second parameter?
        'A: MinimiseUserInteraction If True, all dialogs and messages will be suppressed. Use this when automating a lot of solves so that there are no interruptions. Defaults to False
    End Sub
    

Upvotes: 4

Related Questions