• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 770
  • Last Modified:

VBA to Accept Solver result

I used to know how to do this but have forgotten...

I am running a couple of solver scenarios in sequence, and would rather not click on "OK" to accept the result from each scenario.  This action does not show up in the code when recording a macro.
0
samsoro
Asked:
samsoro
  • 2
1 Solution
 
reedsrCommented:
have you tried:

Application.DisplayAlerts = False

... Code for solver ...

Application.DisplayAlerts = True

make sure you turn it back to true or else you won't get alerts when the macro is done running
0
 
samsoroAuthor Commented:
Actually that does not appear to work either....but I did some further digging and here is the right answer:

SolverSolve userfinish:=True

When recording a macro, it records 'SolverSolve', but not the last part.

If anyone can point me to where documentation on this stuff, I would be happy to award the points.

Thanks.
0
 
reedsrCommented:
SolverSolve Function
See Also Example Specifics
Begins a Solver solution run. Equivalent to clicking Solve in the Solver Parameters dialog box.

Before you use this function, you must establish a reference to the Solver add-in. With a Visual Basic module active, click References on the Tools menu, and then select the Solver.xla check box under Available References. If Solver.xla doesn't appear under Available References, click Browse and open Solver.xla in the \Office\Library subfolder.

SolverSolve(UserFinish, ShowRef)

UserFinish   Optional Variant. True to return the results without displaying the Solver Results dialog box. False or omitted to return the results and display the Solver Results dialog box.

ShowRef   Optional Variant. Used only if True is passed to the StepThru argument of the SolverOptions function. You can pass the name of a macro (as a string) as the ShowRef argument. This macro is then called whenever Solver returns an intermediate solution.


 the example can be found in the VBA help index under SolverSolve;
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now