ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Solver in VBA in a loop (https://www.excelbanter.com/excel-programming/424364-using-solver-vba-loop.html)

Jim[_76_]

Using Solver in VBA in a loop
 
I have used Solver in VBA to solve optimization problems with good
results.
HOWEVER, when I tried to use it in a Monte Carlo For-Next loop, the
debugger highlights the 1st Solver function call.
So here are my questions:
1) Is it possible to execute Solver in a "For-Next" or other loop?
2) Has anyone tried anything similar?
Thanks,
Jim

Jon Peltier

Using Solver in VBA in a loop
 
It's possible and I've done it.

What's your first Solver function call? In fact, I don't see any code here
at all.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
_______


"Jim" wrote in message
...
I have used Solver in VBA to solve optimization problems with good
results.
HOWEVER, when I tried to use it in a Monte Carlo For-Next loop, the
debugger highlights the 1st Solver function call.
So here are my questions:
1) Is it possible to execute Solver in a "For-Next" or other loop?
2) Has anyone tried anything similar?
Thanks,
Jim




Jim[_76_]

Using Solver in VBA in a loop
 
I found the secret.
Apparently loading the SOLVER sla has to be done for each workbook.
Once I did that, everything was fine.
Jim


Jon Peltier

Using Solver in VBA in a loop
 
The xla only needs to be initialized once the first time you use it. But the
model has to be set up for each sheet, because Solver stores the parameters
in the sheet.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
_______


"Jim" wrote in message
...
I found the secret.
Apparently loading the SOLVER sla has to be done for each workbook.
Once I did that, everything was fine.
Jim





All times are GMT +1. The time now is 09:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com