Calling Solver from an Excel 2003 Macro

E

expatgr

When I use Solver manually in my spreadsheet it works as
expected. When I call it from a macro, I get an VBA
error saying that a subroutine or function is not
referenced. When I go to Tools -> References I can't
find Solver.XLA in the tick box list of Addins. Does
anyone know how to force Excel to update this list, to
include the Solver Addin?
 
T

Tom Ogilvy

You have to go to the VBE and go to tools=>references, find solver in the
list and click the box to select it.

http://support.microsoft.com/support/excel/content/solver/solver.asp
Creating Visual Basic Macros that Use Microsoft Excel Solver

or to do it in VBA (post by Dana DeLouis)
http://groups.google.com/groups?threadm=#[email protected]

Sub SolverInstall()
'// Dana DeLouis
Dim wb As Workbook

On Error Resume Next
' Set a Reference to the workbook that will hold Solver
Set wb = ActiveWorkbook

With wb.VBProject.References
.Remove .Item("SOLVER")
End With

With AddIns("Solver Add-In")
.Installed = False
.Installed = True
wb.VBProject.References.AddFromFile .FullName
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top