Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a macro to automate solver 1

Status
Not open for further replies.

IrwinHunter

Technical User
May 30, 2001
12
GB
Microsoft Excel 97
Windows NT

I am trying to produce a Macro that will open up the solver dialogue box in Excel that already has values input and press O.K.

I have used the 'Record new macro' command and followed the steps nescessary.

However when I try and run the macro the Visula Basic De-bugger comes up with "Compile Error: Sub or Function not defined", the de-bugger highlights the 'SolverOK' function in the VB as the problem.

Does anyone know how I can remedy this? Any help would be greaty appreciated.
 
In the VBA editor ,choose Tools>Refrences...then select "solver" from the list....if not available, then you may have to add it from the installation CD.


then your macro should run.
 
Had the same problem. Looked up under Help in VBA window, "SolverOK" gives:

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 \Excel\Library\Solver folder.

I created a reference to solver.xls, which was the only option I could find, and then it worked. It seemed to be necessary to do this for each new workbook created.
 
Hi!

Is there any way to automate this process? I mean, to write a code that would include the reference automatically?

Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top