Thread: solver problems
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
SteveM SteveM is offline
external usenet poster
 
Posts: 133
Default solver problems

You can hide the mess by selecting sheet 1 prior to running the
optimization but first insert

Application.ScreenUpdating = False

before you move to sheet 1. That will maintain the sheet 2 view
during the optimization.

set it to True after you set focus on sheet 2 again.

Something like this:

Sub Optimize

Application.ScreenUpdating = False
Sheets("Sheet 1").Select
SolverSolve UserFinish:=True
Sheets("Sheet 2").Select
Application.ScreenUpdating = True

End Sub

You have to add the Solver dll as a reference to your project (VB Menu
References...) for VB to recognize the Solver functions. Check Help
for more about SolverSolve. You can also capture the Solver
formulation using the Macro recorder and then modify the code to point
to the proper ranges in your formulation. That takes more work, but
it gives you more flexibility.

SteveM



On Nov 11, 9:49 am, wrote:
Right, I currently have a main summary sheet on my second sheet in a
workbook, on this sheet I have a few buttons that will run a number of
different optimizers. One of these optimizers happens to be solver so
when the button is clicked solver is launched and will then run an
optimization on sheet1 but for some reason this doesn't seem to
work... I read somewhere that you can't run an optimization on a
different sheet as to the one solver was launched so I thought I would
work my way around this be making sheet one the active sheet...? now I
could run the optimization on sheet to with a fornula on sheet one
pointing to sheet 2 but this is sucha conveluted mess!

Doesn anyone know a way around this?